Commit 路
97f3f32
1
Parent(s): 1f70da6
feat: fix asr bug
Browse files
app.py
CHANGED
|
@@ -1426,8 +1426,16 @@ with gr.Blocks(title="CityQuest 路 AI") as demo:
|
|
| 1426 |
with gr.Row():
|
| 1427 |
with gr.Column():
|
| 1428 |
gr.HTML("<div class='section-label'>Voice journal</div>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1429 |
d_audio = gr.Audio(sources=["microphone", "upload"], type="filepath",
|
| 1430 |
-
format="wav", label="Record or upload audio"
|
|
|
|
|
|
|
| 1431 |
d_lang = gr.Dropdown(
|
| 1432 |
["en", "fr", "de", "it", "es", "pt", "el", "nl", "pl",
|
| 1433 |
"zh", "ja", "ko", "vi", "ar"],
|
|
@@ -1544,6 +1552,17 @@ with gr.Blocks(title="CityQuest 路 AI") as demo:
|
|
| 1544 |
d_transcribe.click(_btn_off, None, [d_transcribe]).then(
|
| 1545 |
do_transcribe, inputs=[d_audio, d_lang], outputs=[d_transcript]
|
| 1546 |
).then(_btn_on, None, [d_transcribe])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1547 |
d_savejournal.click(_btn_off, None, [d_savejournal]).then(
|
| 1548 |
do_save_journal,
|
| 1549 |
inputs=[s_session, d_transcript, d_audio, d_lang, s_task, s_team],
|
|
|
|
| 1426 |
with gr.Row():
|
| 1427 |
with gr.Column():
|
| 1428 |
gr.HTML("<div class='section-label'>Voice journal</div>")
|
| 1429 |
+
# show_recording_waveform=False makes Gradio use the native
|
| 1430 |
+
# browser <audio> player instead of wavesurfer.js. wavesurfer
|
| 1431 |
+
# decodes the whole clip and paints a waveform on the main
|
| 1432 |
+
# thread (decodeAudioData), which on weaker laptops blocks
|
| 1433 |
+
# long enough to trigger the browser's "Page Unresponsive"
|
| 1434 |
+
# dialog. We don't need the waveform, so turn it off.
|
| 1435 |
d_audio = gr.Audio(sources=["microphone", "upload"], type="filepath",
|
| 1436 |
+
format="wav", label="Record or upload audio",
|
| 1437 |
+
waveform_options=gr.WaveformOptions(
|
| 1438 |
+
show_recording_waveform=False))
|
| 1439 |
d_lang = gr.Dropdown(
|
| 1440 |
["en", "fr", "de", "it", "es", "pt", "el", "nl", "pl",
|
| 1441 |
"zh", "ja", "ko", "vi", "ar"],
|
|
|
|
| 1552 |
d_transcribe.click(_btn_off, None, [d_transcribe]).then(
|
| 1553 |
do_transcribe, inputs=[d_audio, d_lang], outputs=[d_transcript]
|
| 1554 |
).then(_btn_on, None, [d_transcribe])
|
| 1555 |
+
# Auto-transcribe once the clip is actually on the server. stop_recording
|
| 1556 |
+
# (mic) and upload (file) fire *after* Gradio has committed/uploaded the
|
| 1557 |
+
# audio, so do_transcribe always sees a real filepath. This removes the
|
| 1558 |
+
# race where clicking "Transcribe" immediately after recording sent a
|
| 1559 |
+
# stale/None path and seemed to do nothing until you clicked around.
|
| 1560 |
+
d_audio.stop_recording(_btn_off, None, [d_transcribe]).then(
|
| 1561 |
+
do_transcribe, inputs=[d_audio, d_lang], outputs=[d_transcript]
|
| 1562 |
+
).then(_btn_on, None, [d_transcribe])
|
| 1563 |
+
d_audio.upload(_btn_off, None, [d_transcribe]).then(
|
| 1564 |
+
do_transcribe, inputs=[d_audio, d_lang], outputs=[d_transcript]
|
| 1565 |
+
).then(_btn_on, None, [d_transcribe])
|
| 1566 |
d_savejournal.click(_btn_off, None, [d_savejournal]).then(
|
| 1567 |
do_save_journal,
|
| 1568 |
inputs=[s_session, d_transcript, d_audio, d_lang, s_task, s_team],
|