KleinPenny commited on
Commit
5b71666
·
verified ·
1 Parent(s): 97cc5f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -22
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
- audio_interface = gr.Interface(
67
- fn=reverse_audio,
68
- inputs=input_audio,
69
- outputs="audio"
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.launch()
91
- audio_interface.launch()
 
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()