kevinwang676 commited on
Commit
716c66f
·
1 Parent(s): 8f4d804

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -26
app.py CHANGED
@@ -294,19 +294,17 @@ async def text_to_speech_edge(text, voice):
294
 
295
  with gr.Blocks(title="ChatGLM2-6B-int4", theme=gr.themes.Soft(text_size="sm")) as demo:
296
  gr.HTML("<center>"
297
- "<h1>🥳💕🎶 - ChatGLM2 + 声音克隆:和你喜欢的角色畅所欲言吧!</h1>"
298
  "</center>")
299
- gr.Markdown("## <center>💡 - 第二代ChatGLM大语言模型 + FreeVC变声,为您打造独一无二的沉浸式对话体验,支持中英双语</center>")
300
- gr.Markdown("## <center>🌊 - 更多精彩应用,尽在[滔滔AI](http://www.talktalkai.com);滔滔AI,为爱滔滔!💕</center>")
301
- gr.Markdown("### <center>⭐ - 如果您喜欢这个程序,欢迎给我的[Github项目](https://github.com/KevinWang676/ChatGLM2-Voice-Cloning)点赞支持!</center>")
302
 
303
- with gr.Accordion("📒 相关信息", open=False):
304
- _ = f""" ChatGLM2的可选参数信息:
305
  * Low temperature: responses will be more deterministic and focused; High temperature: responses more creative.
306
  * Suggested temperatures -- translation: up to 0.3; chatting: > 0.4
307
- * Top P controls dynamic vocabulary selection based on context.\n
308
- 如果您想让ChatGLM2进行角色扮演并与之对话,请先输入恰当的提示词,如“请你扮演成动漫角色蜡笔小新并和我进行对话”;您也可以为ChatGLM2提供自定义的角色设定\n
309
- 当您使用声音克隆功能时,请先在此程序的对应位置上传一段您喜欢的音频
310
  """
311
  gr.Markdown(dedent(_))
312
  chatbot = gr.Chatbot(height=300)
@@ -314,19 +312,19 @@ with gr.Blocks(title="ChatGLM2-6B-int4", theme=gr.themes.Soft(text_size="sm")) a
314
  with gr.Column(scale=4):
315
  with gr.Column(scale=12):
316
  user_input = gr.Textbox(
317
- label="请在此处和GLM2聊天 (按回车键即可发送)",
318
- placeholder="聊点什么吧",
319
  )
320
  RETRY_FLAG = gr.Checkbox(value=False, visible=False)
321
  with gr.Column(min_width=32, scale=1):
322
  with gr.Row():
323
- submitBtn = gr.Button("开始和GLM2交流吧", variant="primary")
324
- deleteBtn = gr.Button("删除最新一轮对话", variant="secondary")
325
- retryBtn = gr.Button("重新生成最新一轮对话", variant="secondary")
326
 
327
- with gr.Accordion("🔧 更多设置", open=False):
328
  with gr.Row():
329
- emptyBtn = gr.Button("清空所有聊天记录")
330
  max_length = gr.Slider(
331
  0,
332
  32768,
@@ -344,20 +342,20 @@ with gr.Blocks(title="ChatGLM2-6B-int4", theme=gr.themes.Soft(text_size="sm")) a
344
 
345
 
346
  with gr.Row():
347
- test1 = gr.Textbox(label="GLM2的最新回答 (可编辑)", lines = 3)
348
  with gr.Column():
349
- language = gr.Dropdown(choices=voices, value="en-US-AnaNeural-Female", label="请选择文本对应的语言及您喜欢的说话人")
350
- tts_btn = gr.Button("生成对应的音频吧", variant="primary")
351
- output_audio = gr.Audio(type="filepath", label="为您生成的音频", interactive=False)
352
 
353
  tts_btn.click(text_to_speech_edge, inputs=[test1, language], outputs=[output_audio])
354
 
355
  with gr.Row():
356
  model_choice = gr.Dropdown(choices=["FreeVC", "FreeVC-s", "FreeVC (24kHz)"], value="FreeVC (24kHz)", label="Model", visible=False)
357
  audio1 = output_audio
358
- audio2 = gr.Audio(label="请上传您喜欢的声音进行声音克隆", type='filepath')
359
- clone_btn = gr.Button("开始AI声音克隆吧", variant="primary")
360
- audio_cloned = gr.Audio(label="为您生成的专属声音克隆音频", type='filepath')
361
 
362
  clone_btn.click(convert, inputs=[model_choice, audio1, audio2], outputs=[audio_cloned])
363
 
@@ -473,11 +471,11 @@ with gr.Blocks(title="ChatGLM2-6B-int4", theme=gr.themes.Soft(text_size="sm")) a
473
  )
474
  # """
475
 
476
- gr.Markdown("### <center>注意❗:请不要生成会对个人以及组织造成侵害的内容,此程序仅供科研、学习及个人娱乐使用。</center>")
477
- gr.Markdown("<center>💡 - 如何使用此程序:输入您对ChatGLM的提问后,依次点击“开始和GLM2交流吧”、“生成对应的音频吧”、“开始AI声音克隆吧”三个按键即可;使用声音克隆功能时,请先上传一段您喜欢的音频</center>")
478
  gr.HTML('''
479
  <div class="footer">
480
- <p>🌊🏞️🎶 - 江水东流急,滔滔无尽声。 明·顾璘
481
  </p>
482
  </div>
483
  ''')
 
294
 
295
  with gr.Blocks(title="ChatGLM2-6B-int4", theme=gr.themes.Soft(text_size="sm")) as demo:
296
  gr.HTML("<center>"
297
+ "<h1>🥳💕🎶 - ChatGLM2 + Voice Cloning</h1>"
298
  "</center>")
299
+ gr.Markdown("## <center🥳 - Chat with any character you like through ChatGLM2-6B and voice cloning in real time</center>")
300
+ gr.Markdown("## <center>🌊 - Powered by [TalktalkAI](http://www.talktalkai.com)</center>")
301
+ gr.Markdown("### <center>⭐ - If you like the this app, please star my [Github repo](https://github.com/KevinWang676/ChatGLM2-Voice-Cloning).</center>")
302
 
303
+ with gr.Accordion("📒 Info", open=False):
304
+ _ = f""" Some parameters of ChatGLM2:
305
  * Low temperature: responses will be more deterministic and focused; High temperature: responses more creative.
306
  * Suggested temperatures -- translation: up to 0.3; chatting: > 0.4
307
+ * Top P controls dynamic vocabulary selection based on context.
 
 
308
  """
309
  gr.Markdown(dedent(_))
310
  chatbot = gr.Chatbot(height=300)
 
312
  with gr.Column(scale=4):
313
  with gr.Column(scale=12):
314
  user_input = gr.Textbox(
315
+ label="Chat with ChatGLM2 here",
316
+ placeholder="Enter something here...",
317
  )
318
  RETRY_FLAG = gr.Checkbox(value=False, visible=False)
319
  with gr.Column(min_width=32, scale=1):
320
  with gr.Row():
321
+ submitBtn = gr.Button("Chat now!", variant="primary")
322
+ deleteBtn = gr.Button("Delete last turn", variant="secondary")
323
+ retryBtn = gr.Button("Regenerate", variant="secondary")
324
 
325
+ with gr.Accordion("🔧 Settings", open=False):
326
  with gr.Row():
327
+ emptyBtn = gr.Button("Clear History")
328
  max_length = gr.Slider(
329
  0,
330
  32768,
 
342
 
343
 
344
  with gr.Row():
345
+ test1 = gr.Textbox(label="Response from ChatGLM2 (you can edit the content)", lines = 3)
346
  with gr.Column():
347
+ language = gr.Dropdown(choices=voices, value="en-US-AnaNeural-Female", label="Please select a voice")
348
+ tts_btn = gr.Button("Generate", variant="primary")
349
+ output_audio = gr.Audio(type="filepath", label="Audio generated by Edge-TTS", interactive=False)
350
 
351
  tts_btn.click(text_to_speech_edge, inputs=[test1, language], outputs=[output_audio])
352
 
353
  with gr.Row():
354
  model_choice = gr.Dropdown(choices=["FreeVC", "FreeVC-s", "FreeVC (24kHz)"], value="FreeVC (24kHz)", label="Model", visible=False)
355
  audio1 = output_audio
356
+ audio2 = gr.Audio(label="Upload reference audio for voice cloning (~5s)", type='filepath')
357
+ clone_btn = gr.Button("Generate", variant="primary")
358
+ audio_cloned = gr.Audio(label="Generated audio in a custom voice", type='filepath')
359
 
360
  clone_btn.click(convert, inputs=[model_choice, audio1, audio2], outputs=[audio_cloned])
361
 
 
471
  )
472
  # """
473
 
474
+ gr.Markdown("### <center>❗ Please do not generate content that could infringe upon the rights or cause harm to individuals or organizations.</center>")
475
+ gr.Markdown("<center>💡 - How to use this app:After sending your questions to ChatGLM2, click </center>")
476
  gr.HTML('''
477
  <div class="footer">
478
+ <p>🌊🏞️🎶 - Powered by talktalkai
479
  </p>
480
  </div>
481
  ''')