Real-Time Subtitling for Live Streams

Job ID: 38725848

Budget: €30 – €250 EUR

Project Title: Real-Time Subtitling with Google Cloud Speech-to-Text and Translation APIs

Project Overview:
We need a Python script that captures audio from a live video stream (typically an IPTV stream played in VLC), processes it with Google’s Speech-to-Text API to transcribe and timestamp the audio, and then uses Google’s Translation API to translate the transcription into another language (e.g., Portuguese to English). The translated text should then be output as subtitles in real time, with accurate timing, to a subtitle file (SRT format) that can be displayed alongside the video.

Key Requirements:

1. Audio Recording in Intervals:
• Capture audio in 30-second intervals continuously, ensuring that no audio is missed between intervals.
• Use Google Speech-to-Text API to transcribe the recorded audio in Portuguese, and generate timestamps that reflect the actual timing of the video.
2. Real-Time Timestamps:
• Timestamps should begin at a specific start time (e.g., 00:01:00) and should align with the actual playback timing of the video.
• Use an offset system to account for the time delay caused by API processing, ensuring subtitles are synchronized with the video.
3. Translation:
• Use Google Translation API to translate the transcribed text into English (or other target languages).
• Combine all transcriptions within each 30-second recording as a single subtitle entry, simplifying debugging and reducing API call complexity.
4. SRT File Generation:
• Generate an SRT file with accurate timestamps based on the real-time delay and video playback.
• Each SRT entry should display the entire transcription for each 30-second chunk.
• Handle cases where subtitles come back out of order or have overlapping timestamps.
5. Error Handling and Logging:
• Log the start and completion time of each API call, the time taken for API responses, and any errors encountered.
• Ensure the script handles potential API rate limits and failures gracefully, including retries or fallbacks.
6. Platform Requirements:
• The solution should run on Windows and be compatible with VLC and MPV media players, as we’re using these to display the video and subtitles.

Ideal Developer Skills:

• Experience with Python, especially in handling continuous audio processing and real-time applications.
• Familiarity with Google Cloud APIs, particularly Speech-to-Text and Translation.
• Experience generating subtitle files (SRT format) and synchronizing them with video playback.
• Ability to implement error handling, logging, and optimization for API-based solutions.

Additional Notes:

• We have a one-minute video delay that needs to be accounted for, so subtitles should begin appearing at 00:01:00 to align with this delay.
• The script should ideally keep track of any delay between recordings and API responses to ensure continuous audio capture and translation.
• Please include clear comments and documentation to enable future adjustments or troubleshooting.

I already have a script but the subtitle timestamps are not functioning correctly so you could either write it from scratch or debug mine