Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,7 +109,7 @@ def main(audio):
|
|
| 109 |
context = transcribe_audio(audio)
|
| 110 |
|
| 111 |
if "Error" in context:
|
| 112 |
-
return context
|
| 113 |
|
| 114 |
answers = fill_textboxes(context)
|
| 115 |
answers.insert(0, "") # for "Child's Name"
|
|
@@ -120,23 +120,25 @@ def main(audio):
|
|
| 120 |
def save_answers(*args):
|
| 121 |
answers_dict = {oral_health_assessment_form[i]: args[i] for i in range(len(oral_health_assessment_form))}
|
| 122 |
print("Saved answers:", answers_dict)
|
| 123 |
-
return "
|
| 124 |
|
| 125 |
# Create the Gradio interface
|
| 126 |
with gr.Blocks() as demo:
|
| 127 |
gr.Markdown("# Audio Transcription and Question Answering App")
|
| 128 |
-
|
|
|
|
|
|
|
|
|
|
| 129 |
with gr.Column():
|
| 130 |
-
|
| 131 |
-
output_html = gr.HTML(label="Assessment Form")
|
| 132 |
-
transcribe_button = gr.Button("Transcribe and Generate Form")
|
| 133 |
-
|
| 134 |
with gr.Column():
|
| 135 |
-
|
| 136 |
-
submit_button = gr.Button("Submit")
|
| 137 |
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
| 140 |
|
| 141 |
# Launch the app
|
| 142 |
demo.launch()
|
|
|
|
| 109 |
context = transcribe_audio(audio)
|
| 110 |
|
| 111 |
if "Error" in context:
|
| 112 |
+
return [context] * len(oral_health_assessment_form)
|
| 113 |
|
| 114 |
answers = fill_textboxes(context)
|
| 115 |
answers.insert(0, "") # for "Child's Name"
|
|
|
|
| 120 |
def save_answers(*args):
|
| 121 |
answers_dict = {oral_health_assessment_form[i]: args[i] for i in range(len(oral_health_assessment_form))}
|
| 122 |
print("Saved answers:", answers_dict)
|
| 123 |
+
return f"Saved answers: {answers_dict}"
|
| 124 |
|
| 125 |
# Create the Gradio interface
|
| 126 |
with gr.Blocks() as demo:
|
| 127 |
gr.Markdown("# Audio Transcription and Question Answering App")
|
| 128 |
+
audio_input = gr.Audio(type="filepath", label="Record your audio", elem_id="audio_input")
|
| 129 |
+
transcribe_button = gr.Button("Transcribe and Generate Form", elem_id="transcribe_button")
|
| 130 |
+
|
| 131 |
+
with gr.Row(elem_id="textboxes_row"):
|
| 132 |
with gr.Column():
|
| 133 |
+
textboxes_left = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(0, len(oral_health_assessment_form)//2)]
|
|
|
|
|
|
|
|
|
|
| 134 |
with gr.Column():
|
| 135 |
+
textboxes_right = [gr.Textbox(label=oral_health_assessment_form[i], value="", interactive=True) for i in range(len(oral_health_assessment_form)//2, len(oral_health_assessment_form))]
|
|
|
|
| 136 |
|
| 137 |
+
submit_button = gr.Button("Submit", elem_id="submit_button")
|
| 138 |
+
output_html = gr.HTML(label="Submitted Answers")
|
| 139 |
+
|
| 140 |
+
transcribe_button.click(fn=main, inputs=audio_input, outputs=textboxes_left + textboxes_right)
|
| 141 |
+
submit_button.click(fn=save_answers, inputs=textboxes_left + textboxes_right, outputs=output_html)
|
| 142 |
|
| 143 |
# Launch the app
|
| 144 |
demo.launch()
|