Spaces:
Paused
Paused
Commit ·
6a28beb
1
Parent(s): 6dba563
feat: auto-start mic recording on Ask click (100ms user gesture window)
Browse filesCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
app.py
CHANGED
|
@@ -1032,6 +1032,23 @@ with gr.Blocks(title="MomsVoice", css=css_code) as demo:
|
|
| 1032 |
inputs=[],
|
| 1033 |
outputs=[player_status_bar, play_btn, pause_btn, ask_btn, resume_btn, qa_panel, qa_input_group, answer_display, answer_audio],
|
| 1034 |
cancels=[play_event],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1035 |
)
|
| 1036 |
|
| 1037 |
# 9. Submit question — LFM2.5-Audio end-to-end (single model: audio-in → audio+text-out)
|
|
|
|
| 1032 |
inputs=[],
|
| 1033 |
outputs=[player_status_bar, play_btn, pause_btn, ask_btn, resume_btn, qa_panel, qa_input_group, answer_display, answer_audio],
|
| 1034 |
cancels=[play_event],
|
| 1035 |
+
js="""() => {
|
| 1036 |
+
// Auto-click Record within user gesture window (100ms).
|
| 1037 |
+
// The Ask button click IS the user gesture, so mic permission should be granted.
|
| 1038 |
+
setTimeout(() => {
|
| 1039 |
+
const el = document.querySelector('#qa_audio_input');
|
| 1040 |
+
if (!el) return;
|
| 1041 |
+
const btn = el.querySelector('button[aria-label="Record"], button.record-button');
|
| 1042 |
+
if (btn) { btn.click(); return; }
|
| 1043 |
+
// Fallback: find any button with record icon
|
| 1044 |
+
const allBtns = el.querySelectorAll('button');
|
| 1045 |
+
for (const b of allBtns) {
|
| 1046 |
+
if (b.querySelector('svg') || b.textContent.trim() === '') {
|
| 1047 |
+
b.click(); break;
|
| 1048 |
+
}
|
| 1049 |
+
}
|
| 1050 |
+
}, 100);
|
| 1051 |
+
}"""
|
| 1052 |
)
|
| 1053 |
|
| 1054 |
# 9. Submit question — LFM2.5-Audio end-to-end (single model: audio-in → audio+text-out)
|