Update app.py
Browse files
app.py
CHANGED
@@ -34,16 +34,16 @@ def predict(input, history=None):
|
|
34 |
history = []
|
35 |
response, history = model.chat(tokenizer, input, history)
|
36 |
|
37 |
-
return history, history,
|
|
|
|
|
38 |
|
39 |
-
def chinese(audio, upload1, VoiceMicrophone1):
|
40 |
-
|
41 |
if upload1 is not None:
|
42 |
|
43 |
-
tts.voice_conversion_to_file(source_wav=
|
44 |
|
45 |
else:
|
46 |
-
tts.voice_conversion_to_file(source_wav=
|
47 |
|
48 |
|
49 |
noisy = enhance_model.load_audio(
|
@@ -81,17 +81,17 @@ with gr.Blocks() as demo:
|
|
81 |
)
|
82 |
state = gr.State([])
|
83 |
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=300)
|
84 |
-
|
85 |
with gr.Row():
|
86 |
# with gr.Column(scale=4):
|
87 |
txt = gr.Textbox(label = "说点什么吧(中英皆可)", lines=1)
|
88 |
# with gr.Column(scale=1):
|
89 |
button = gr.Button("开始对话吧")
|
90 |
-
txt.submit(predict, [txt, state], [chatbot, state,
|
91 |
-
button.click(predict, [txt, state], [chatbot, state,
|
92 |
|
93 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
94 |
-
inp3 =
|
95 |
inp4 = gr.Audio(source="upload", label = "请上传您喜欢的声音(wav/mp3文件);长语音(90s左右)效果更好", type="filepath")
|
96 |
inp5 = gr.Audio(source="microphone", type="filepath", label = '请用麦克风上传您喜欢的声音,与文件上传二选一即可')
|
97 |
btn1 = gr.Button("用喜欢的声音听一听吧(中文)")
|
|
|
34 |
history = []
|
35 |
response, history = model.chat(tokenizer, input, history)
|
36 |
|
37 |
+
return history, history, response
|
38 |
+
|
39 |
+
def chinese(text_cn, upload1, VoiceMicrophone1):
|
40 |
|
|
|
|
|
41 |
if upload1 is not None:
|
42 |
|
43 |
+
tts.voice_conversion_to_file(source_wav=inference(text_cn), target_wav=upload1, file_path="output0.wav")
|
44 |
|
45 |
else:
|
46 |
+
tts.voice_conversion_to_file(source_wav=inference(text_cn), target_wav=VoiceMicrophone1, file_path="output0.wav")
|
47 |
|
48 |
|
49 |
noisy = enhance_model.load_audio(
|
|
|
81 |
)
|
82 |
state = gr.State([])
|
83 |
chatbot = gr.Chatbot([], elem_id="chatbot").style(height=300)
|
84 |
+
res = gr.Textbox(lines=1, placeholder="最新的回答在这里", show_label = False).style(container=False)
|
85 |
with gr.Row():
|
86 |
# with gr.Column(scale=4):
|
87 |
txt = gr.Textbox(label = "说点什么吧(中英皆可)", lines=1)
|
88 |
# with gr.Column(scale=1):
|
89 |
button = gr.Button("开始对话吧")
|
90 |
+
txt.submit(predict, [txt, state], [chatbot, state, res])
|
91 |
+
button.click(predict, [txt, state], [chatbot, state, res])
|
92 |
|
93 |
with gr.Row().style(mobile_collapse=False, equal_height=True):
|
94 |
+
inp3 = res
|
95 |
inp4 = gr.Audio(source="upload", label = "请上传您喜欢的声音(wav/mp3文件);长语音(90s左右)效果更好", type="filepath")
|
96 |
inp5 = gr.Audio(source="microphone", type="filepath", label = '请用麦克风上传您喜欢的声音,与文件上传二选一即可')
|
97 |
btn1 = gr.Button("用喜欢的声音听一听吧(中文)")
|