kevinwang676
commited on
Commit
•
4a01738
1
Parent(s):
018f7e9
Update app.py
Browse files
app.py
CHANGED
@@ -80,7 +80,7 @@ def convert(api_key, text, tgt, voice, save_path):
|
|
80 |
client = OpenAI(api_key=api_key)
|
81 |
|
82 |
response = client.audio.speech.create(
|
83 |
-
model="tts-1
|
84 |
voice=voice,
|
85 |
input=text,
|
86 |
)
|
@@ -223,7 +223,7 @@ def merge_audios(folder_path):
|
|
223 |
return "AI配音版.wav"
|
224 |
|
225 |
import shutil
|
226 |
-
|
227 |
def convert_from_srt(apikey, filename, audio_full, voice, multilingual):
|
228 |
subtitle_list = read_srt(filename)
|
229 |
|
@@ -240,8 +240,6 @@ def convert_from_srt(apikey, filename, audio_full, voice, multilingual):
|
|
240 |
print(f"正在合成第{i.index}条语音")
|
241 |
print(f"语音内容:{i.text}")
|
242 |
convert(apikey, i.text, f"sliced_audio_{i.index}_0.wav", voice, i.text + " " + str(i.index))
|
243 |
-
time.sleep(2)
|
244 |
-
print("程序休息2秒")
|
245 |
else:
|
246 |
for i in subtitle_list:
|
247 |
os.makedirs("output", exist_ok=True)
|
@@ -249,8 +247,6 @@ def convert_from_srt(apikey, filename, audio_full, voice, multilingual):
|
|
249 |
print(f"正在合成第{i.index}条语音")
|
250 |
print(f"语音内容:{i.text.splitlines()[1]}")
|
251 |
convert(apikey, i.text.splitlines()[1], f"sliced_audio_{i.index}_0.wav", voice, i.text.splitlines()[1] + " " + str(i.index))
|
252 |
-
time.sleep(2)
|
253 |
-
print("程序休息2秒")
|
254 |
|
255 |
merge_audios("output")
|
256 |
|
|
|
80 |
client = OpenAI(api_key=api_key)
|
81 |
|
82 |
response = client.audio.speech.create(
|
83 |
+
model="tts-1",
|
84 |
voice=voice,
|
85 |
input=text,
|
86 |
)
|
|
|
223 |
return "AI配音版.wav"
|
224 |
|
225 |
import shutil
|
226 |
+
|
227 |
def convert_from_srt(apikey, filename, audio_full, voice, multilingual):
|
228 |
subtitle_list = read_srt(filename)
|
229 |
|
|
|
240 |
print(f"正在合成第{i.index}条语音")
|
241 |
print(f"语音内容:{i.text}")
|
242 |
convert(apikey, i.text, f"sliced_audio_{i.index}_0.wav", voice, i.text + " " + str(i.index))
|
|
|
|
|
243 |
else:
|
244 |
for i in subtitle_list:
|
245 |
os.makedirs("output", exist_ok=True)
|
|
|
247 |
print(f"正在合成第{i.index}条语音")
|
248 |
print(f"语音内容:{i.text.splitlines()[1]}")
|
249 |
convert(apikey, i.text.splitlines()[1], f"sliced_audio_{i.index}_0.wav", voice, i.text.splitlines()[1] + " " + str(i.index))
|
|
|
|
|
250 |
|
251 |
merge_audios("output")
|
252 |
|