jinggujiwoo7
commited on
Commit
β’
45b9570
1
Parent(s):
c53ff7e
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
|
|
2 |
|
3 |
# μ μ₯λ μμ± νμΌμ κ΄λ¦¬νλ λμ
λ리
|
4 |
recordings = {}
|
|
|
|
|
5 |
|
6 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
7 |
def teacher_question(question):
|
@@ -18,6 +20,15 @@ def record_student_voice(question, voice):
|
|
18 |
recordings[question] = [voice]
|
19 |
return "Voice recorded successfully!"
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
# Gradio μΈν°νμ΄μ€ μ μ
|
22 |
with gr.Blocks() as demo:
|
23 |
with gr.Tab("Teacher's Question"):
|
@@ -27,15 +38,26 @@ with gr.Blocks() as demo:
|
|
27 |
submit_question.click(teacher_question, inputs=question_input, outputs=[output_question])
|
28 |
|
29 |
with gr.Tab("Record Voice"):
|
30 |
-
|
31 |
voice_input = gr.Audio(type="numpy", label="Record your voice")
|
32 |
submit_voice = gr.Button("Submit Voice")
|
33 |
output_voice = gr.Textbox(label="Status")
|
34 |
-
submit_voice.click(record_student_voice, inputs=[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
def
|
37 |
-
|
38 |
|
39 |
-
demo.load(
|
|
|
40 |
|
41 |
demo.launch()
|
|
|
2 |
|
3 |
# μ μ₯λ μμ± νμΌμ κ΄λ¦¬νλ λμ
λ리
|
4 |
recordings = {}
|
5 |
+
# μ μ₯λ λ΅κΈμ κ΄λ¦¬νλ λμ
λ리
|
6 |
+
comments = {}
|
7 |
|
8 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
9 |
def teacher_question(question):
|
|
|
20 |
recordings[question] = [voice]
|
21 |
return "Voice recorded successfully!"
|
22 |
|
23 |
+
# λ΅κΈ μμ±
|
24 |
+
def write_comment(question, comment):
|
25 |
+
global comments
|
26 |
+
if question in comments:
|
27 |
+
comments[question].append(comment)
|
28 |
+
else:
|
29 |
+
comments[question] = [comment]
|
30 |
+
return "Comment added successfully!"
|
31 |
+
|
32 |
# Gradio μΈν°νμ΄μ€ μ μ
|
33 |
with gr.Blocks() as demo:
|
34 |
with gr.Tab("Teacher's Question"):
|
|
|
38 |
submit_question.click(teacher_question, inputs=question_input, outputs=[output_question])
|
39 |
|
40 |
with gr.Tab("Record Voice"):
|
41 |
+
question_select = gr.Dropdown(label="Select a question to record voice")
|
42 |
voice_input = gr.Audio(type="numpy", label="Record your voice")
|
43 |
submit_voice = gr.Button("Submit Voice")
|
44 |
output_voice = gr.Textbox(label="Status")
|
45 |
+
submit_voice.click(record_student_voice, inputs=[question_select, voice_input], outputs=output_voice)
|
46 |
+
|
47 |
+
with gr.Tab("Write Comment"):
|
48 |
+
comment_question_input = gr.Dropdown(label="Select a question to write comment")
|
49 |
+
comment_input = gr.Textbox(placeholder="Your comment", label="Comment")
|
50 |
+
submit_comment = gr.Button("Submit Comment")
|
51 |
+
output_comment = gr.Textbox(label="Status")
|
52 |
+
submit_comment.click(write_comment, inputs=[comment_question_input, comment_input], outputs=output_comment)
|
53 |
+
|
54 |
+
def update_question_select(question):
|
55 |
+
question_select.choices = [question]
|
56 |
|
57 |
+
def update_comment_select(question):
|
58 |
+
comment_question_input.choices = [question]
|
59 |
|
60 |
+
demo.load(update_question_select, inputs=output_question)
|
61 |
+
demo.load(update_comment_select, inputs=output_question)
|
62 |
|
63 |
demo.launch()
|