Update app.py
Browse files
app.py
CHANGED
@@ -61,42 +61,24 @@ def assistant(*audio_answers):
|
|
61 |
score = ask_questions(text_answers)
|
62 |
return summarized_text, f"Your score is: {score}/{len(questions)}", text_answers # Return text_answers as well
|
63 |
|
64 |
-
# Create the Gradio Blocks interface with button click
|
65 |
-
|
66 |
-
def update():
|
67 |
-
audio_answers = [audio.value for audio in inp] # Using inp as it collects all the audio inputs
|
68 |
-
|
69 |
-
# Check if all questions have been answered
|
70 |
-
# if None in audio_answers:
|
71 |
-
# out_last_transcription.value = "Please answer all the questions before clicking Run."
|
72 |
-
# out_score.value = ""
|
73 |
-
# return
|
74 |
-
|
75 |
-
# Handling the three returned values from the assistant function
|
76 |
-
summarized_text, score_string, text_answers = assistant(*audio_answers)
|
77 |
-
out_last_transcription.value = summarized_text # Displaying the summarized text
|
78 |
-
out_score.value = score_string # Displaying the score
|
79 |
|
80 |
with gr.Blocks() as demo:
|
81 |
gr.Markdown("Start recording your responses below and then click **Run** to see the transcription and your score.")
|
82 |
|
83 |
-
# Clearly initializing Inputs and Outputs lists for the button click
|
84 |
-
inp = []
|
85 |
-
|
86 |
# Using Column to nest questions
|
87 |
with gr.Column(scale=1, min_width=600):
|
|
|
88 |
for i, question in enumerate(questions):
|
89 |
gr.Markdown(f"**Question {i+1}:** {question}")
|
90 |
audio_input = gr.Audio(source="microphone")
|
91 |
inp.append(audio_input)
|
92 |
|
93 |
-
#
|
94 |
out_last_transcription = gr.Textbox(label="Last Transcribed Answer", placeholder="Last transcribed answer will appear here.")
|
95 |
out_score = gr.Textbox(label="Score", placeholder="Your score will appear here.")
|
96 |
|
97 |
-
# Button
|
98 |
-
|
99 |
-
btn.click(fn=update, inputs=inp, outputs=[out_last_transcription, out_score])
|
100 |
|
101 |
|
102 |
demo.launch()
|
|
|
61 |
score = ask_questions(text_answers)
|
62 |
return summarized_text, f"Your score is: {score}/{len(questions)}", text_answers # Return text_answers as well
|
63 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
with gr.Blocks() as demo:
|
66 |
gr.Markdown("Start recording your responses below and then click **Run** to see the transcription and your score.")
|
67 |
|
|
|
|
|
|
|
68 |
# Using Column to nest questions
|
69 |
with gr.Column(scale=1, min_width=600):
|
70 |
+
inp = []
|
71 |
for i, question in enumerate(questions):
|
72 |
gr.Markdown(f"**Question {i+1}:** {question}")
|
73 |
audio_input = gr.Audio(source="microphone")
|
74 |
inp.append(audio_input)
|
75 |
|
76 |
+
# Output textboxes for the last transcribed answer and the score
|
77 |
out_last_transcription = gr.Textbox(label="Last Transcribed Answer", placeholder="Last transcribed answer will appear here.")
|
78 |
out_score = gr.Textbox(label="Score", placeholder="Your score will appear here.")
|
79 |
|
80 |
+
# Button to run the assistant function
|
81 |
+
gr.Button(value="Run", function=assistant, inputs=inp, outputs=[out_last_transcription, out_score])
|
|
|
82 |
|
83 |
|
84 |
demo.launch()
|