GCLing commited on
Commit
78bdf71
·
verified ·
1 Parent(s): a6fb2f2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -168,17 +168,19 @@ def build_interface():
168
  with gr.TabItem("臉部情緒"):
169
  gr.Markdown("### 臉部情緒 (即時 Webcam Streaming 分析)")
170
  with gr.Row():
171
- webcam = gr.Image(tool="webcam", streaming=True, type="numpy", label="攝像頭畫面")
 
172
  face_out = gr.Label(label="情緒分布")
173
  webcam.stream(fn=predict_face, inputs=webcam, outputs=face_out)
174
 
 
175
  # 語音 Tab
176
  with gr.TabItem("語音情緒"):
177
  gr.Markdown("### 語音情緒 分析")
178
  with gr.Row():
179
  audio = gr.Audio(source="microphone", streaming=False, type="filepath", label="錄音")
180
  voice_out = gr.Label(label="語音情緒結果")
181
- audio.change(fn=predict_voice, inputs=audio, outputs=voice_out)
182
 
183
  # 文字 Tab
184
  with gr.TabItem("文字情緒"):
@@ -187,6 +189,10 @@ def build_interface():
187
  text = gr.Textbox(lines=3, placeholder="請輸入中文文字…")
188
  text_out = gr.Label(label="文字情緒結果")
189
  text.submit(fn=predict_text_mixed, inputs=text, outputs=text_out)
 
 
 
 
190
  # 或按鈕:
191
  # btn = gr.Button("分析")
192
  # btn.click(fn=predict_text_mixed, inputs=text, outputs=text_out)
 
168
  with gr.TabItem("臉部情緒"):
169
  gr.Markdown("### 臉部情緒 (即時 Webcam Streaming 分析)")
170
  with gr.Row():
171
+ # 改为 gr.Camera
172
+ webcam = gr.Camera(streaming=True, type="numpy", label="攝像頭畫面")
173
  face_out = gr.Label(label="情緒分布")
174
  webcam.stream(fn=predict_face, inputs=webcam, outputs=face_out)
175
 
176
+
177
  # 語音 Tab
178
  with gr.TabItem("語音情緒"):
179
  gr.Markdown("### 語音情緒 分析")
180
  with gr.Row():
181
  audio = gr.Audio(source="microphone", streaming=False, type="filepath", label="錄音")
182
  voice_out = gr.Label(label="語音情緒結果")
183
+ audio.change(fn=predict_voice, inputs=audio, outputs=voice_out)
184
 
185
  # 文字 Tab
186
  with gr.TabItem("文字情緒"):
 
189
  text = gr.Textbox(lines=3, placeholder="請輸入中文文字…")
190
  text_out = gr.Label(label="文字情緒結果")
191
  text.submit(fn=predict_text_mixed, inputs=text, outputs=text_out)
192
+ # 或者按钮:
193
+ # btn = gr.Button("分析")
194
+ # btn.click(fn=predict_text_mixed, inputs=text, outputs=text_out)
195
+
196
  # 或按鈕:
197
  # btn = gr.Button("分析")
198
  # btn.click(fn=predict_text_mixed, inputs=text, outputs=text_out)