Portfolio

Current projects

Translator tool (click to view)

SQL project/Linux sim (click to view)


Translator tool technology overview:

The system’s logic is distributed across PHP (backend automation and REST APIs) and JavaScript (frontend interactivity).

Each component interacts through WordPress hooks, REST routes, and external SDK calls to create a seamless end-to-end pipeline.

1. File Upload & Automation (PHP – Upload Portal Template)

Key Functions:

wp_handle_upload() – securely processes the uploaded video file and stores it in the WordPress uploads directory.

wp_insert_post() – automatically generates a new post for each successful upload, embedding the video player and transcription container.

update_post_meta() – saves metadata such as file paths, processing status, and translation progress for internal use.

do_action() hooks (e.g., after_video_upload) – trigger conversion and transcription tasks asynchronously after upload.

Purpose:

These functions handle file security, automate post creation, and pass the uploaded file to the backend processing chain without manual intervention.

2. Audio Conversion & Cloud Integration

Key Functions:

new CloudConvert(['api_key' => CLOUDCONVERT_API_KEY]) – initializes the CloudConvert API client.

$cloudconvert->jobs()->create([...]) – sends the uploaded video for conversion to a standardized FLAC/WAV format at 44.1kHz.

wp_remote_get() and wp_remote_post() – handle communication with external APIs where direct SDK integration isn’t required.

Purpose:

Ensures all audio files conform to the correct format for speech recognition, minimizing errors in the transcription stage.

3. Speech-to-Text Transcription (Google Cloud SDK)

Key Functions:

$speechClient = new Google\Cloud\Speech\V1\SpeechClient([...]) – authenticates to Google Cloud using a secure key.

$speechClient->recognize($config, $audio) – performs the actual transcription, returning structured text results.

file_put_contents() – saves the transcription to a local or cloud storage location.

wp_update_post() – updates the WordPress post to include the video and its generated transcript.

Purpose:

Automates transcription generation and embeds the text content beneath the video for readability.

4. Translation REST Endpoint (PHP – functions.php)

Key Functions:

register_rest_route('video/v1', '/translate', [...]) – defines a custom REST endpoint accessible via JavaScript.

sanitize_text_field() and intval() – ensure input validation and prevent injection attacks.

$translate = new Google\Cloud\Translate\V2\TranslateClient(['key' => TRANSLATE_API_KEY]) – initializes the Google Translate client.

$translate->translate($text, ['target' => $lang]) – performs dynamic translation based on the language dropdown selection.

wp_send_json_success() and wp_send_json_error() – send JSON responses back to the frontend for AJAX processing.

Purpose:

Allows the frontend to request on-demand translations of the transcription securely through WordPress’s REST API infrastructure.

5. Text-to-Speech Generation (AWS Polly)

Key Functions:

$polly = new Aws\Polly\PollyClient([...]) – connects to AWS Polly using stored credentials.

$polly->synthesizeSpeech([...]) – converts the translated text into a spoken audio file.

file_put_contents() + wp_upload_bits() – store the resulting audio and attach it to the post as a playable element.

Purpose:

Transforms translations into natural-sounding voiceovers, enabling multilingual dubbing directly from the same user interface.

6. Frontend Interactivity (JavaScript – translation.js)

Key Functions:

document.addEventListener('DOMContentLoaded', …) – initializes after the page loads.

fetch('/wp-json/video/v1/translate', { method: 'POST', … }) – sends AJAX requests to the REST API when the user selects a language.

innerHTML and style.display – dynamically update translation results and toggle the audio player visibility.

Scrollable containers are styled using CSS overflow:auto for transcript and translation readability.

Purpose:

Provides a responsive, no-reload user experience where translations and dubbing occur dynamically via RESTful communication.

7. Configuration & Security (wp-config.php)

Key Elements:

define('TRANSLATE_API_KEY', 'your-key');

define('AWS_POLLY_KEY', 'your-key');

Purpose:

All cost-per-use API keys are stored as constants in the secure configuration layer — never exposed in the theme or public directories.