Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -63,29 +63,31 @@ input_audio = gr.Audio(
|
|
63 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
64 |
"""
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
|
72 |
-
demo = gr.ChatInterface(
|
73 |
-
respond,
|
74 |
-
additional_inputs=[
|
75 |
-
gr.Textbox(value="You are a friendly Chatbot.", label="System message"),
|
76 |
-
gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"),
|
77 |
-
gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"),
|
78 |
-
gr.Slider(
|
79 |
-
minimum=0.1,
|
80 |
-
maximum=1.0,
|
81 |
-
value=0.95,
|
82 |
-
step=0.05,
|
83 |
-
label="Top-p (nucleus sampling)",
|
84 |
-
),
|
85 |
-
],
|
86 |
-
)
|
87 |
|
88 |
|
89 |
if __name__ == "__main__":
|
90 |
-
demo
|
91 |
-
|
|
|
63 |
For information on how to customize the ChatInterface, peruse the gradio docs: https://www.gradio.app/docs/chatinterface
|
64 |
"""
|
65 |
|
66 |
+
# 创建 Gradio 接口
|
67 |
+
def create_interface():
|
68 |
+
with gr.Blocks() as demo:
|
69 |
+
# 标题
|
70 |
+
gr.Markdown("# 语音识别与生成系统")
|
71 |
+
|
72 |
+
# 输入部分:音频上传
|
73 |
+
with gr.Row():
|
74 |
+
audio_input = gr.Audio(source="microphone", type="filepath", label="录制音频")
|
75 |
+
|
76 |
+
# 输出部分:文本识别结果和音频播放
|
77 |
+
with gr.Row():
|
78 |
+
recognized_text = gr.Textbox(label="识别文本")
|
79 |
+
audio_output = gr.Audio(label="生成的语音")
|
80 |
+
|
81 |
+
# 处理按钮
|
82 |
+
process_button = gr.Button("处理音频")
|
83 |
+
|
84 |
+
# 绑定处理逻辑
|
85 |
+
process_button.click(process_audio, inputs=[audio_input], outputs=[recognized_text, audio_output])
|
86 |
+
|
87 |
+
return demo
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
|
91 |
if __name__ == "__main__":
|
92 |
+
demo = create_interface()
|
93 |
+
demo.launch()
|