Skip to content

Added multilingual caption support#16

Open
hemant838 wants to merge 3 commits into
smallest-inc:mainfrom
hemant838:multling/caption
Open

Added multilingual caption support#16
hemant838 wants to merge 3 commits into
smallest-inc:mainfrom
hemant838:multling/caption

Conversation

@hemant838

@hemant838 hemant838 commented Feb 13, 2026

Copy link
Copy Markdown

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.

  • Implemented Gradio-based application in app.py with TranscriptionSession and CaptionAccumulator classes
  • Integrated Smallest AI Pulse STT WebSocket API with language=multi parameter for auto-detection
  • Added OpenAI GPT-4o-mini integration for live translation to multiple target languages
  • Included audio resampling, streaming, and real-time SRT caption formatting
  • Added comprehensive documentation, environment configuration template, and numpy dependency
  • Updated main README with new example entry and improved table formatting

Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/websocket/multilingual-live-captions/app.py Outdated
Comment thread speech-to-text/subtitle_utils.py
Comment thread speech-to-text/subtitle_utils.py
Comment thread speech-to-text/subtitle_utils.py
Comment thread speech-to-text/subtitle_utils.py
Comment thread speech-to-text/websocket/stt_session.py
Comment thread speech-to-text/websocket/stt_session.py
Comment thread speech-to-text/websocket/stt_session.py
Comment thread speech-to-text/websocket/stt_session.py
Comment thread speech-to-text/websocket/stt_session.py
Comment thread speech-to-text/websocket/stt_session.py
@abhishekmishragithub

Copy link
Copy Markdown
Collaborator

@hemant838 do you wanna update your PR based on the current model changes?
you can checkout the docs here: waves-docs.smallest.ai/v4.0.0/content/api-references/

@vercel

vercel Bot commented Mar 23, 2026

Copy link
Copy Markdown

@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.

@hemant838

Copy link
Copy Markdown
Author

done @abhishekmishragithub can you please check

@entelligence-ai-pr-reviews

Copy link
Copy Markdown


Confidence Score: 3/5 - Review Recommended

  • 12 unresolved comment(s) from previous reviews still need to be addressed
  • 6/9 changed files reviewed (67% coverage)

@entelligence-ai-pr-reviews entelligence-ai-pr-reviews Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Duplicate Code Detected

Found 2 duplicate function(s) in this PR. Consider consolidating to reduce code duplication.

Comment on lines +11 to +29
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}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code: ⚠️ Duplicate Code Detected (Similarity: 95%)

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.

Comment on lines +32 to +50
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}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code: ⚠️ Duplicate Code Detected (Similarity: 95%)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants