Spaces:
Paused
Paused
Commit ·
26ea281
1
Parent(s): 21973a3
fix: dedup only on auto-submit, manual Get Answer always works
Browse filesCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
app.py
CHANGED
|
@@ -1039,9 +1039,6 @@ with gr.Blocks(title="MomsVoice", css=css_code) as demo:
|
|
| 1039 |
q_txt = (question_txt or "").strip()
|
| 1040 |
has_audio = question_audio_path is not None and question_audio_path != ""
|
| 1041 |
|
| 1042 |
-
if has_audio and not claim_audio_submission(question_audio_path):
|
| 1043 |
-
return gr.update(), gr.update()
|
| 1044 |
-
|
| 1045 |
result = build_qa_response(
|
| 1046 |
question_text=q_txt,
|
| 1047 |
question_audio_path=question_audio_path if has_audio else None,
|
|
@@ -1050,8 +1047,6 @@ with gr.Blocks(title="MomsVoice", css=css_code) as demo:
|
|
| 1050 |
answer_fn=answer_question_audio,
|
| 1051 |
max_new_tokens=100,
|
| 1052 |
)
|
| 1053 |
-
if has_audio and result.get("error"):
|
| 1054 |
-
release_audio_submission(question_audio_path)
|
| 1055 |
|
| 1056 |
if not result["ok"]:
|
| 1057 |
answer_html = """
|
|
@@ -1086,11 +1081,14 @@ with gr.Blocks(title="MomsVoice", css=css_code) as demo:
|
|
| 1086 |
)
|
| 1087 |
|
| 1088 |
# Auto-submit when voice recording completes. .change() fires after the
|
| 1089 |
-
# recorded audio file path is committed
|
|
|
|
| 1090 |
def auto_submit_on_audio(audio_path, question_txt, paragraphs, slider_val, profile_id):
|
| 1091 |
"""Auto-submit when a recording is available."""
|
| 1092 |
if not audio_path:
|
| 1093 |
return gr.update(), gr.update()
|
|
|
|
|
|
|
| 1094 |
return handle_question_submit(question_txt, audio_path, paragraphs, slider_val, profile_id)
|
| 1095 |
|
| 1096 |
question_audio.change(
|
|
|
|
| 1039 |
q_txt = (question_txt or "").strip()
|
| 1040 |
has_audio = question_audio_path is not None and question_audio_path != ""
|
| 1041 |
|
|
|
|
|
|
|
|
|
|
| 1042 |
result = build_qa_response(
|
| 1043 |
question_text=q_txt,
|
| 1044 |
question_audio_path=question_audio_path if has_audio else None,
|
|
|
|
| 1047 |
answer_fn=answer_question_audio,
|
| 1048 |
max_new_tokens=100,
|
| 1049 |
)
|
|
|
|
|
|
|
| 1050 |
|
| 1051 |
if not result["ok"]:
|
| 1052 |
answer_html = """
|
|
|
|
| 1081 |
)
|
| 1082 |
|
| 1083 |
# Auto-submit when voice recording completes. .change() fires after the
|
| 1084 |
+
# recorded audio file path is committed. Dedup prevents double-submit if
|
| 1085 |
+
# the user also clicks "Get Answer" manually.
|
| 1086 |
def auto_submit_on_audio(audio_path, question_txt, paragraphs, slider_val, profile_id):
|
| 1087 |
"""Auto-submit when a recording is available."""
|
| 1088 |
if not audio_path:
|
| 1089 |
return gr.update(), gr.update()
|
| 1090 |
+
if not claim_audio_submission(audio_path):
|
| 1091 |
+
return gr.update(), gr.update()
|
| 1092 |
return handle_question_submit(question_txt, audio_path, paragraphs, slider_val, profile_id)
|
| 1093 |
|
| 1094 |
question_audio.change(
|