Spaces:
Sleeping
Sleeping
Commit
·
9c31286
1
Parent(s):
7f042d6
Update app.py
Browse files
app.py
CHANGED
@@ -85,7 +85,10 @@ def convert(model, src, tgt):
|
|
85 |
|
86 |
# GLM2
|
87 |
|
88 |
-
language_dict = tts_order_voice
|
|
|
|
|
|
|
89 |
|
90 |
# fix timezone in Linux
|
91 |
os.environ["TZ"] = "Asia/Shanghai"
|
@@ -276,8 +279,7 @@ def print(text):
|
|
276 |
|
277 |
# TTS
|
278 |
|
279 |
-
async def text_to_speech_edge(text,
|
280 |
-
voice = language_dict[language_code]
|
281 |
communicate = edge_tts.Communicate(text, voice)
|
282 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
283 |
tmp_path = tmp_file.name
|
@@ -341,7 +343,7 @@ with gr.Blocks(title="ChatGLM2-6B-int4", theme=gr.themes.Soft(text_size="sm")) a
|
|
341 |
with gr.Row():
|
342 |
test1 = gr.Textbox(label="GLM2的最新回答 (可编辑)", lines = 3)
|
343 |
with gr.Column():
|
344 |
-
language = gr.Dropdown(choices=
|
345 |
tts_btn = gr.Button("生成对应的音频吧", variant="primary")
|
346 |
output_audio = gr.Audio(type="filepath", label="为您生成的音频", interactive=False)
|
347 |
|
|
|
85 |
|
86 |
# GLM2
|
87 |
|
88 |
+
#language_dict = tts_order_voice
|
89 |
+
|
90 |
+
tts_voice_list = asyncio.get_event_loop().run_until_complete(edge_tts.list_voices())
|
91 |
+
voices = [f"{v['ShortName']}-{v['Gender']}" for v in tts_voice_list]
|
92 |
|
93 |
# fix timezone in Linux
|
94 |
os.environ["TZ"] = "Asia/Shanghai"
|
|
|
279 |
|
280 |
# TTS
|
281 |
|
282 |
+
async def text_to_speech_edge(text, voice):
|
|
|
283 |
communicate = edge_tts.Communicate(text, voice)
|
284 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".mp3") as tmp_file:
|
285 |
tmp_path = tmp_file.name
|
|
|
343 |
with gr.Row():
|
344 |
test1 = gr.Textbox(label="GLM2的最新回答 (可编辑)", lines = 3)
|
345 |
with gr.Column():
|
346 |
+
language = gr.Dropdown(choices=voices, value="普通话 (中国大陆)-Xiaoxiao-女", label="请选择文本对应的语言及您喜欢的说话人")
|
347 |
tts_btn = gr.Button("生成对应的音频吧", variant="primary")
|
348 |
output_audio = gr.Audio(type="filepath", label="为您生成的音频", interactive=False)
|
349 |
|