ZiyuG commited on
Commit
f470955
1 Parent(s): ad8b014

Update audio.py

Browse files
Files changed (1) hide show
  1. audio.py +4 -4
audio.py CHANGED
@@ -57,14 +57,14 @@ def gen_audio(subtitles, tmpdir):
57
  duration = end_time - start_time
58
 
59
  # tts = gTTS(text=text, lang='yue')
60
- audio_path = os.path.join(temp_audio_path, f'subtitle_{i}.wav')
61
  # tts.save(audio_path)
62
  ms_tts_gen(text, audio_path)
63
 
64
- audio_segment = AudioSegment.from_wav(audio_path)
65
 
66
- new_audio_path = os.path.join(temp_audio_path, f'subtitle_{i}_adjusted.wav')
67
- audio_segment.export(new_audio_path, format="wav")
68
 
69
  audio_clip = AudioFileClip(new_audio_path).set_start(start_time).set_duration(min(duration, audio_segment.duration_seconds))
70
 
 
57
  duration = end_time - start_time
58
 
59
  # tts = gTTS(text=text, lang='yue')
60
+ audio_path = os.path.join(temp_audio_path, f'subtitle_{i}.mp3')
61
  # tts.save(audio_path)
62
  ms_tts_gen(text, audio_path)
63
 
64
+ audio_segment = AudioSegment.from_mp3(audio_path)
65
 
66
+ new_audio_path = os.path.join(temp_audio_path, f'subtitle_{i}_adjusted.mp3')
67
+ audio_segment.export(new_audio_path, format="mp3")
68
 
69
  audio_clip = AudioFileClip(new_audio_path).set_start(start_time).set_duration(min(duration, audio_segment.duration_seconds))
70