Added multilingual caption support#16
Conversation
|
@hemant838 do you wanna update your PR based on the current model changes? |
|
@hemant838 is attempting to deploy a commit to the developer-2074's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
done @abhishekmishragithub can you please check |
Confidence Score: 3/5 - Review Recommended
|
| def format_timestamp_srt(seconds: float) -> str: | ||
| """ | ||
| Format seconds to SRT timestamp format: HH:MM:SS,mmm | ||
|
|
||
| Args: | ||
| seconds: Time in seconds (can be float) | ||
|
|
||
| Returns: | ||
| Formatted timestamp string in SRT format | ||
|
|
||
| Example: | ||
| >>> format_timestamp_srt(65.123) | ||
| '00:01:05,123' | ||
| """ | ||
| ms = int(seconds * 1000) | ||
| hours, ms = divmod(ms, 3600 * 1000) | ||
| minutes, ms = divmod(ms, 60 * 1000) | ||
| secs, ms = divmod(ms, 1000) | ||
| return f"{hours:02d}:{minutes:02d}:{secs:02d},{ms:03d}" |
There was a problem hiding this comment.
Duplicate Code:
This function format_timestamp_srt duplicates existing code.
📍 Original Location:
speech-to-text/subtitle-generation/javascript/transcribe.js:48-54
Function: formatTimeSrt
💡 Recommendation:
Since these are in different languages, full consolidation isn't possible, but the Python version in subtitle_utils.py should be treated as the canonical implementation for Python consumers. The JS version in transcribe.js should remain separate. Document that both implement the same spec so they stay in sync.
Consider importing and reusing the existing function instead of duplicating the logic.
| def format_timestamp_vtt(seconds: float) -> str: | ||
| """ | ||
| Format seconds to VTT timestamp format: HH:MM:SS.mmm | ||
|
|
||
| Args: | ||
| seconds: Time in seconds (can be float) | ||
|
|
||
| Returns: | ||
| Formatted timestamp string in VTT format | ||
|
|
||
| Example: | ||
| >>> format_timestamp_vtt(65.123) | ||
| '00:01:05.123' | ||
| """ | ||
| ms = int(seconds * 1000) | ||
| hours, ms = divmod(ms, 3600 * 1000) | ||
| minutes, ms = divmod(ms, 60 * 1000) | ||
| secs, ms = divmod(ms, 1000) | ||
| return f"{hours:02d}:{minutes:02d}:{secs:02d}.{ms:03d}" |
There was a problem hiding this comment.
Duplicate Code:
This function format_timestamp_vtt duplicates existing code.
📍 Original Location:
speech-to-text/subtitle-generation/javascript/transcribe.js:56-62
Function: formatTimeVtt
💡 Recommendation:
Same as format_timestamp_srt: treat subtitle_utils.py as the canonical Python implementation. Add cross-language documentation noting both versions must use . as separator.
Consider importing and reusing the existing function instead of duplicating the logic.
Adds a new Speech-to-Text example that demonstrates automatic language detection, real-time translation, and live SRT caption generation for events and streams.
What's New
New example: speech-to-text/websocket/multilingual-live-captions/
Gradio web UI for live microphone transcription with translation
Automatic language detection using Pulse STT's language=multi parameter
On-the-fly translation via OpenAI (optional, graceful fallback to source text)
Real-time SRT preview for copy/paste into caption tools or video players
Features
Auto language detection – Pulse STT automatically identifies spoken language
Live translation – Translates captions to target language (English, Spanish, French, German, Hindi, Portuguese, Japanese, or keep source)
SRT preview – Generates properly formatted SubRip captions with timestamps
Lightweight resampling – Client-side audio resampling using numpy interpolation
Error resilience – Falls back to source text if translation fails
Files Added
app.py – Main application with WebSocket streaming, translation, and SRT generation
README.md – Usage instructions, features, and configuration
requirements.txt – Additional dependency (numpy)
.env.sample – Environment variable template
EntelligenceAI PR Summary
This PR adds a new multilingual live captions feature with automatic language detection, real-time translation, and SRT subtitle generation for speech-to-text WebSocket functionality.
app.pywith TranscriptionSession and CaptionAccumulator classeslanguage=multiparameter for auto-detection