NeuralFalcon commited on
Commit
b3f10b4
·
verified ·
1 Parent(s): eec06c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -13
app.py CHANGED
@@ -292,19 +292,37 @@ import time
292
 
293
  # os.chdir(install_path)
294
 
295
- def your_tts(text,audio_path,actual_duration,speed=1.0):
296
- global srt_voice_name
297
- model_name="kokoro-v0_19.pth"
298
- tts_path=text_to_speech(text, model_name, voice_name=srt_voice_name,speed=speed,trim=1.0)
299
- # print(tts_path)
300
- tts_audio = AudioSegment.from_file(tts_path)
301
- tts_duration = len(tts_audio)
302
- if tts_duration > actual_duration:
303
- speedup_factor = tts_duration / actual_duration
304
- tts_path=text_to_speech(text, model_name, voice_name=srt_voice_name,speed=speedup_factor,trim=1.0)
305
- # print(tts_path)
306
- shutil.copy(tts_path,audio_path)
307
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
 
309
 
310
  base_path="."
 
292
 
293
  # os.chdir(install_path)
294
 
295
+ # def your_tts(text,audio_path,actual_duration,speed=1.0):
296
+ # global srt_voice_name
297
+ # model_name="kokoro-v0_19.pth"
298
+ # tts_path=text_to_speech(text, model_name, voice_name=srt_voice_name,speed=speed,trim=1.0)
299
+ # # print(tts_path)
300
+ # tts_audio = AudioSegment.from_file(tts_path)
301
+ # tts_duration = len(tts_audio)
302
+ # if tts_duration > actual_duration:
303
+ # speedup_factor = tts_duration / actual_duration
304
+ # tts_path=text_to_speech(text, model_name, voice_name=srt_voice_name,speed=speedup_factor,trim=1.0)
305
+ # # print(tts_path)
306
+ # shutil.copy(tts_path,audio_path)
307
+
308
+
309
+ def your_tts(text, audio_path, actual_duration, speed=1.0):
310
+ global srt_voice_name
311
+ model_name = "kokoro-v0_19.pth"
312
+
313
+ # Generate TTS audio
314
+ tts_path = text_to_speech(text, model_name, voice_name=srt_voice_name, speed=speed, trim=1.0)
315
+ tts_audio = AudioSegment.from_file(tts_path)
316
+ tts_duration = len(tts_audio)
317
+
318
+ if actual_duration > 0:
319
+ if tts_duration > actual_duration:
320
+ speedup_factor = tts_duration / actual_duration
321
+ tts_path = text_to_speech(text, model_name, voice_name=srt_voice_name, speed=speedup_factor, trim=1.0)
322
+ else:
323
+ pass
324
+
325
+ shutil.copy(tts_path, audio_path)
326
 
327
 
328
  base_path="."