Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -152,7 +152,7 @@ def translate_local(text_to_translate, target_lang='ta-IN', device=None):
|
|
| 152 |
chunks.append(current_chunk.strip())
|
| 153 |
|
| 154 |
# 4. Translate each chunk and combine the results
|
| 155 |
-
translator = MyMemoryTranslator(source='en-GB', target=
|
| 156 |
translated_chunks = []
|
| 157 |
for chunk in chunks:
|
| 158 |
try:
|
|
@@ -177,7 +177,7 @@ def synthesize_speech(synth_text, target_lang, gender="Male", pace="normal", out
|
|
| 177 |
print("> Loading IndicF5 TTS model (ai4bharat/IndicF5)...")
|
| 178 |
indicf5_repo_id = "ai4bharat/IndicF5"
|
| 179 |
token = os.environ.get("HF_TOKEN")
|
| 180 |
-
tts_model = AutoModel.from_pretrained(indicf5_repo_id, token=token, trust_remote_code=True
|
| 181 |
|
| 182 |
audio = tts_model(synth_text, ref_audio_path=ref_audio_path, ref_text=ref_text)
|
| 183 |
|
|
@@ -260,8 +260,8 @@ def audio_pipeline_run(audio_path,target_lang):
|
|
| 260 |
original_text , pace = transcribe_audio(audio_path)
|
| 261 |
translated_text = translate_local(original_text,target_lang)
|
| 262 |
translated_audio = synthesize_speech(translated_text, target_lang, "Male", pace)
|
| 263 |
-
synced_translated_audio = match_audio_duration(
|
| 264 |
-
cloned_synced_translated_audio = clone_voice(
|
| 265 |
return cloned_synced_translated_audio
|
| 266 |
|
| 267 |
|
|
|
|
| 152 |
chunks.append(current_chunk.strip())
|
| 153 |
|
| 154 |
# 4. Translate each chunk and combine the results
|
| 155 |
+
translator = MyMemoryTranslator(source='en-GB', target=target_lang)
|
| 156 |
translated_chunks = []
|
| 157 |
for chunk in chunks:
|
| 158 |
try:
|
|
|
|
| 177 |
print("> Loading IndicF5 TTS model (ai4bharat/IndicF5)...")
|
| 178 |
indicf5_repo_id = "ai4bharat/IndicF5"
|
| 179 |
token = os.environ.get("HF_TOKEN")
|
| 180 |
+
tts_model = AutoModel.from_pretrained(indicf5_repo_id, token=token, trust_remote_code=True, device_map=device)
|
| 181 |
|
| 182 |
audio = tts_model(synth_text, ref_audio_path=ref_audio_path, ref_text=ref_text)
|
| 183 |
|
|
|
|
| 260 |
original_text , pace = transcribe_audio(audio_path)
|
| 261 |
translated_text = translate_local(original_text,target_lang)
|
| 262 |
translated_audio = synthesize_speech(translated_text, target_lang, "Male", pace)
|
| 263 |
+
synced_translated_audio = match_audio_duration(audio_path, translated_audio)
|
| 264 |
+
cloned_synced_translated_audio = clone_voice(audio_path, synced_translated_audio, target_lang, "Male", pace)
|
| 265 |
return cloned_synced_translated_audio
|
| 266 |
|
| 267 |
|