Views
No views yet
models/
├── whisper/ # Speech Recognition Models
├── nllb-200-distilled-600M-ct2-int8/ # Translation Model (Fast)
├── nllb-200-distilled-1.3B-ct2-int8/ # Translation Model (Accurate)
├── models--facebook--mms-tts-eng/ # English Voice Synthesis
└── models--facebook--mms-tts-fra/ # French Voice Synthesisexamples/
├── input_audio/ # Test audio files (English & French samples)
└── output_audio/ # Expected translation results1torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cpu (For CPU inference)
2torch==2.6.0 torchvision==0.21.0 torchaudio==2.6.0 --index-url https://download.pytorch.org/whl/cu126 (For GPU inference)
3faster-whisper==1.1.1
4ctranslate2==4.4.0
5transformers==4.52.3
6numpy==2.2.6
7scipy==1.15.3
8gradio==5.31.0
9requests==2.32.3$ pip install -r requirements.txt1from enhanced_s2s_pipeline import EnhancedS2SPipeline
2
3# Initialize with GPU support
4pipeline = EnhancedS2SPipeline(device="cuda")1# Process audio file
2for status, transcript, translation, output_audio in pipeline.process_speech_to_speech_realtime(
3 audio_file="examples/input_audio/eng1.wav",
4 source_lang="English",
5 target_lang="French",
6 whisper_model="small",
7 nllb_model="600M"
8):
9 print(f"Status: {status}")
10 print(f"Original: {transcript}")
11 print(f"Translation: {translation}")1model_configs = {
2 "nllb": {
3 "600M": {
4 "path": "./models/nllb-200-distilled-600M-ct2-int8",
5 "size": "600M parameters",
6 "speed": "Fast"
7 },
8 "1.3B": {
9 "path": "./models/nllb-200-distilled-1.3B-ct2-int8",
10 "size": "1.3B parameters",
11 "speed": "Medium"
12 }
13 }
14}1result = pipeline.process_speech_to_speech_realtime(
2 audio_file="input.wav",
3 source_lang="French",
4 target_lang="English",
5 whisper_model="small", # Better accuracy
6 nllb_model="1.3B", # Highest quality
7 whisper_beam_size=5, # Thorough search
8 nllb_beam_size=4, # Quality translation
9 length_penalty=1.2, # Prefer complete sentences
10 speaking_rate=1.0 # Natural speed
11)| Use Case | Whisper | NLLB | Total Size | Speed |
|---|---|---|---|---|
| Demo/Testing | tiny | 600M | ~699MB | Very Fast |
| Production | base | 600M | ~768MB | Fast |
| High Quality | small | 1.3B | ~1.9GB | Medium |
| Maximum Accuracy | small | 1.3B | ~1.9GB | Slower |
1# Test English to French
2$ python test_translation.py --input examples/input_audio/eng1.wav --source English --target French
3
4# Test French to English
5$ python test_translation.py --input examples/input_audio/fr1.wav --source French --target English1# Check if models load correctly
2pipeline = EnhancedS2SPipeline(device="cuda")
3whisper_model = pipeline.get_whisper_model("tiny")
4nllb_model = pipeline.get_nllb_model("600M")
5print("✅ All models loaded successfully!")1import gradio as gr
2from enhanced_s2s_pipeline import EnhancedS2SPipeline
3
4pipeline = EnhancedS2SPipeline()
5
6def translate_audio(audio_file, source_lang, target_lang):
7 for status, transcript, translation, output in pipeline.process_speech_to_speech_realtime(
8 audio_file=audio_file,
9 source_lang=source_lang,
10 target_lang=target_lang
11 ):
12 return status, transcript, translation, output
13
14demo = gr.Interface(
15 fn=translate_audio,
16 inputs=[
17 gr.Audio(type="filepath"),
18 gr.Radio(["English", "French"]),
19 gr.Radio(["English", "French"])
20 ],
21 outputs=[
22 gr.Textbox(label="Status"),
23 gr.Textbox(label="Original"),
24 gr.Textbox(label="Translation"),
25 gr.Audio(label="Output")
26 ]
27)
28
29demo.launch()1# Load models only when needed
2pipeline = EnhancedS2SPipeline(device="cuda")
3# Models are loaded dynamically during first use1audio_files = ["file1.wav", "file2.wav", "file3.wav"]
2for audio_file in audio_files:
3 result = pipeline.process_speech_to_speech_realtime(
4 audio_file=audio_file,
5 source_lang="English",
6 target_lang="French"
7 )1# Use smaller models or CPU
2pipeline = EnhancedS2SPipeline(device="cpu")1# Check file paths
2$ ls -la models/nllb-200-distilled-600M-ct2-int8/1# Convert audio to supported format
2import librosa
3audio, sr = librosa.load("input.mp3", sr=16000)
4librosa.output.write_wav("input.wav", audio, sr)@repository{enhanced-speech-translation-models,
title={Enhanced Speech-to-Speech Translation Models},
author={pruthvi423},
year={2025},
url={https://huggingface.co/pruthvi423/speech-translation-models}
}
