prasanacodes commited on
Commit
e7f93f6
·
verified ·
1 Parent(s): 63b261d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -170,10 +170,10 @@ def translate_local(text_to_translate, target_lang='ta-IN', device=None):
170
 
171
  return translated_text
172
 
173
- def synthesize_speech(synth_text, target_lang, gender="Male", pace="normal", output_path="temp_audio_synthesized.wav", device="cpu"):
174
-
175
- ref_audio_path = str('reference/'+target_lang.upper()+'/'+gender.upper()+'_'+pace.upper()+'.wav')
176
- ref_text_path = str('reference/'+target_lang.upper()+'/'+gender.upper()+'_'+pace.upper()+'.txt')
177
 
178
  ref_audio_path = ref_audio_path
179
  with open(ref_text_path, encoding='utf-8') as f:
@@ -260,7 +260,7 @@ def main_run(video_path,target_lang,user_transcript=None, user_translation=None)
260
  else:
261
  translated_text = translate_local(original_text,target_lang)
262
  print(f"Translated Text: {translated_text}")
263
- translated_audio = synthesize_speech(translated_text, target_lang, "Male", pace)
264
  synced_translated_audio = match_audio_duration(original_audio_file, translated_audio)
265
  cloned_synced_translated_audio = clone_voice(synced_translated_audio, original_audio_file)
266
  final_video_nobgm = merge_audio_video(video_path, cloned_synced_translated_audio)
@@ -280,7 +280,7 @@ def audio_pipeline_run(audio_path,target_lang,user_transcript=None, user_transla
280
  else:
281
  translated_text = translate_local(original_text,target_lang)
282
  print(f"Translated Text: {translated_text}")
283
- translated_audio = synthesize_speech(translated_text, target_lang, "Male", pace)
284
  synced_translated_audio = match_audio_duration(audio_path, translated_audio)
285
  cloned_synced_translated_audio = clone_voice(synced_translated_audio, audio_path)
286
  print(f"✅ Pipeline finished")
 
170
 
171
  return translated_text
172
 
173
+ def synthesize_speech(synth_text, target_lang, pace="normal", output_path="temp_audio_synthesized.wav", device="cpu"):
174
+
175
+ ref_audio_path = str('reference/TAMIL/MALE_'+pace.upper()+'.wav')
176
+ ref_text_path = str('reference/TAMIL/MALE_'+pace.upper()+'.txt')
177
 
178
  ref_audio_path = ref_audio_path
179
  with open(ref_text_path, encoding='utf-8') as f:
 
260
  else:
261
  translated_text = translate_local(original_text,target_lang)
262
  print(f"Translated Text: {translated_text}")
263
+ translated_audio = synthesize_speech(translated_text, target_lang, pace)
264
  synced_translated_audio = match_audio_duration(original_audio_file, translated_audio)
265
  cloned_synced_translated_audio = clone_voice(synced_translated_audio, original_audio_file)
266
  final_video_nobgm = merge_audio_video(video_path, cloned_synced_translated_audio)
 
280
  else:
281
  translated_text = translate_local(original_text,target_lang)
282
  print(f"Translated Text: {translated_text}")
283
+ translated_audio = synthesize_speech(translated_text, target_lang, pace)
284
  synced_translated_audio = match_audio_duration(audio_path, translated_audio)
285
  cloned_synced_translated_audio = clone_voice(synced_translated_audio, audio_path)
286
  print(f"✅ Pipeline finished")