Update app.py
Browse files
app.py
CHANGED
@@ -62,7 +62,8 @@ def transcribe_audio(audio_file, lang_code):
|
|
62 |
|
63 |
with gr.Blocks(title="氫鬆聊 - 專屬於您的健康諮詢夥伴") as demo:
|
64 |
gr.HTML(INTRO_TEXT)
|
65 |
-
chatbot = gr.Chatbot(height=400)
|
|
|
66 |
with gr.Row():
|
67 |
msg = gr.Textbox(label="請輸入您的問題", placeholder="例如:我正在接受__治療,可以吃___?")
|
68 |
lang_select = gr.Dropdown(
|
@@ -79,16 +80,19 @@ with gr.Blocks(title="氫鬆聊 - 專屬於您的健康諮詢夥伴") as demo:
|
|
79 |
],
|
80 |
value="zh-TW"
|
81 |
)
|
|
|
82 |
with gr.Row():
|
83 |
-
audio_input = gr.Audio(
|
84 |
-
voice_to_text = gr.Button("🎤
|
|
|
85 |
with gr.Row():
|
86 |
ask = gr.Button("提問")
|
87 |
clear = gr.Button("清除對話")
|
88 |
|
89 |
def respond(message, history):
|
90 |
reply = call_gemini(message)
|
91 |
-
history.append(
|
|
|
92 |
return "", history
|
93 |
|
94 |
def handle_audio(audio_path, lang_code):
|
|
|
62 |
|
63 |
with gr.Blocks(title="氫鬆聊 - 專屬於您的健康諮詢夥伴") as demo:
|
64 |
gr.HTML(INTRO_TEXT)
|
65 |
+
chatbot = gr.Chatbot(height=400, type="messages")
|
66 |
+
|
67 |
with gr.Row():
|
68 |
msg = gr.Textbox(label="請輸入您的問題", placeholder="例如:我正在接受__治療,可以吃___?")
|
69 |
lang_select = gr.Dropdown(
|
|
|
80 |
],
|
81 |
value="zh-TW"
|
82 |
)
|
83 |
+
|
84 |
with gr.Row():
|
85 |
+
audio_input = gr.Audio(label="🎙 請錄音", type="filepath")
|
86 |
+
voice_to_text = gr.Button("🎤 語音轉文字")
|
87 |
+
|
88 |
with gr.Row():
|
89 |
ask = gr.Button("提問")
|
90 |
clear = gr.Button("清除對話")
|
91 |
|
92 |
def respond(message, history):
|
93 |
reply = call_gemini(message)
|
94 |
+
history.append({"role": "user", "content": message})
|
95 |
+
history.append({"role": "assistant", "content": reply})
|
96 |
return "", history
|
97 |
|
98 |
def handle_audio(audio_path, lang_code):
|