|
@@ -19,6 +19,7 @@ import math
|
|
|
import dataset
|
|
|
from datetime import datetime
|
|
|
from gtts import gTTS
|
|
|
+import ffmpy
|
|
|
|
|
|
dir_sound = 'mp3_track/'
|
|
|
dir_photo = 'photo/'
|
|
@@ -138,10 +139,15 @@ def file_prepare(name, name_hash,text_content,image_urls,multiLang,lang='zh'):
|
|
|
if lang!='zh' or multiLang==1:
|
|
|
if lang!='zh':
|
|
|
tts = gTTS(txt)
|
|
|
- tts.save(dir_sound+name_hash+"/"+str(txt_idx)+".mp3")
|
|
|
+ tts.save(dir_sound+name_hash+"/"+str(txt_idx)+"raw.mp3")
|
|
|
else:
|
|
|
tts = gTTS(txt,lang='zh-tw')
|
|
|
- tts.save(dir_sound+name_hash+"/"+str(txt_idx)+".mp3")
|
|
|
+ tts.save(dir_sound+name_hash+"/"+str(txt_idx)+"raw.mp3")
|
|
|
+ #speed up
|
|
|
+ ff = ffmpy.FFmpeg(inputs={dir_sound+name_hash+"/"+str(txt_idx)+"raw.mp3": None}
|
|
|
+ , outputs={dir_sound+name_hash+"/"+str(txt_idx)+".mp3": ["-filter:a", "atempo=1.2"]})
|
|
|
+ ff.run()
|
|
|
+ os.remove(dir_sound+name_hash+"/"+str(txt_idx)+"raw.mp3")
|
|
|
else:
|
|
|
print('use zhtts')
|
|
|
tts = zhtts.TTS()
|