Update bots/test.py
Browse files- bots/test.py +10 -7
bots/test.py
CHANGED
|
@@ -30,21 +30,24 @@ async def synthesize_audio(gpt_model_path, sovits_model_path, ref_audio_path, re
|
|
| 30 |
await asyncio.to_thread(change_gpt_weights, gpt_path=gpt_model_path)
|
| 31 |
await asyncio.to_thread(change_sovits_weights, sovits_path=sovits_model_path)
|
| 32 |
|
| 33 |
-
synthesis_result =
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
result_list = list(synthesis_result)
|
| 40 |
if result_list:
|
| 41 |
last_sampling_rate, last_audio_data = result_list[-1]
|
| 42 |
last_audio_data = remove_silence(last_audio_data)
|
|
|
|
|
|
|
|
|
|
| 43 |
output_wav_path = os.path.join(output_path, "output.wav")
|
| 44 |
sf.write(output_wav_path, last_audio_data, last_sampling_rate)
|
| 45 |
return output_wav_path
|
| 46 |
return None
|
| 47 |
-
|
| 48 |
@client.command(name="say")
|
| 49 |
async def synthesize(ctx, *, target_text: str):
|
| 50 |
ref_text = "幽魂盯上你了,進入射擊位置"
|
|
@@ -71,4 +74,4 @@ async def synthesize(ctx, *, target_text: str):
|
|
| 71 |
else:
|
| 72 |
await ctx.send("請先進入語音頻道!")
|
| 73 |
else:
|
| 74 |
-
await ctx.send("合成失敗!")
|
|
|
|
| 30 |
await asyncio.to_thread(change_gpt_weights, gpt_path=gpt_model_path)
|
| 31 |
await asyncio.to_thread(change_sovits_weights, sovits_path=sovits_model_path)
|
| 32 |
|
| 33 |
+
synthesis_result = await asyncio.to_thread(get_tts_wav, ref_wav_path=ref_audio_path,
|
| 34 |
+
prompt_text=ref_text,
|
| 35 |
+
prompt_language=language_combobox,
|
| 36 |
+
text=target_text,
|
| 37 |
+
text_language=language_combobox_02)
|
| 38 |
|
| 39 |
result_list = list(synthesis_result)
|
| 40 |
if result_list:
|
| 41 |
last_sampling_rate, last_audio_data = result_list[-1]
|
| 42 |
last_audio_data = remove_silence(last_audio_data)
|
| 43 |
+
|
| 44 |
+
if not os.path.exists(output_path):
|
| 45 |
+
os.makedirs(output_path)
|
| 46 |
output_wav_path = os.path.join(output_path, "output.wav")
|
| 47 |
sf.write(output_wav_path, last_audio_data, last_sampling_rate)
|
| 48 |
return output_wav_path
|
| 49 |
return None
|
| 50 |
+
|
| 51 |
@client.command(name="say")
|
| 52 |
async def synthesize(ctx, *, target_text: str):
|
| 53 |
ref_text = "幽魂盯上你了,進入射擊位置"
|
|
|
|
| 74 |
else:
|
| 75 |
await ctx.send("請先進入語音頻道!")
|
| 76 |
else:
|
| 77 |
+
await ctx.send("合成失敗!")
|