jinggujiwoo7
commited on
Commit
β’
c558203
1
Parent(s):
4b559b2
Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,16 @@ import gradio as gr
|
|
2 |
|
3 |
# μ μ₯λ μμ± νμΌμ κ΄λ¦¬νλ λμ
λ리
|
4 |
recordings = {}
|
5 |
-
|
6 |
-
|
|
|
7 |
submitted_question = ""
|
8 |
|
9 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
10 |
def teacher_question(question):
|
11 |
global submitted_question
|
12 |
submitted_question = question
|
13 |
-
return
|
14 |
|
15 |
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
|
16 |
def record_student_voice(voice):
|
@@ -24,22 +25,42 @@ def record_student_voice(voice):
|
|
24 |
else:
|
25 |
return "Please submit a question first."
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
# Gradio μΈν°νμ΄μ€ μ μ
|
28 |
with gr.Blocks() as demo:
|
29 |
with gr.Tab("Teacher's Question"):
|
30 |
question_input = gr.Textbox(lines=2, placeholder="Enter your question here...", label="Teacher's Question")
|
31 |
submit_question = gr.Button("Submit")
|
32 |
output_question = gr.Textbox(label="Submitted Question")
|
33 |
-
submit_question.click(teacher_question, inputs=question_input, outputs=
|
34 |
|
35 |
with gr.Tab("Record Voice"):
|
|
|
|
|
36 |
submit_voice = gr.Button("Submit Voice")
|
37 |
output_voice = gr.Textbox(label="Status")
|
38 |
-
submit_voice.click(record_student_voice, outputs=output_voice)
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
|
40 |
-
def update_question_display(
|
41 |
-
|
42 |
|
43 |
-
demo.load(update_question_display,
|
44 |
|
45 |
demo.launch()
|
|
|
2 |
|
3 |
# μ μ₯λ μμ± νμΌμ κ΄λ¦¬νλ λμ
λ리
|
4 |
recordings = {}
|
5 |
+
# μ μ₯λ λκΈμ κ΄λ¦¬νλ λμ
λ리
|
6 |
+
comments = {}
|
7 |
+
# μ μλμ΄ μ μΆν μ§λ¬Έμ μ μ₯νλ λ³μ
|
8 |
submitted_question = ""
|
9 |
|
10 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
11 |
def teacher_question(question):
|
12 |
global submitted_question
|
13 |
submitted_question = question
|
14 |
+
return question
|
15 |
|
16 |
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
|
17 |
def record_student_voice(voice):
|
|
|
25 |
else:
|
26 |
return "Please submit a question first."
|
27 |
|
28 |
+
# λκΈ μ μ₯
|
29 |
+
def write_comment(comment):
|
30 |
+
global submitted_question
|
31 |
+
if submitted_question:
|
32 |
+
if submitted_question in comments:
|
33 |
+
comments[submitted_question].append(comment)
|
34 |
+
else:
|
35 |
+
comments[submitted_question] = [comment]
|
36 |
+
return "Comment added successfully for question: " + submitted_question
|
37 |
+
else:
|
38 |
+
return "Please submit a question first."
|
39 |
+
|
40 |
# Gradio μΈν°νμ΄μ€ μ μ
|
41 |
with gr.Blocks() as demo:
|
42 |
with gr.Tab("Teacher's Question"):
|
43 |
question_input = gr.Textbox(lines=2, placeholder="Enter your question here...", label="Teacher's Question")
|
44 |
submit_question = gr.Button("Submit")
|
45 |
output_question = gr.Textbox(label="Submitted Question")
|
46 |
+
submit_question.click(teacher_question, inputs=question_input, outputs=output_question)
|
47 |
|
48 |
with gr.Tab("Record Voice"):
|
49 |
+
question_display = gr.Textbox(label="Question", interactive=False)
|
50 |
+
voice_input = gr.Audio(type="numpy", label="Record your voice")
|
51 |
submit_voice = gr.Button("Submit Voice")
|
52 |
output_voice = gr.Textbox(label="Status")
|
53 |
+
submit_voice.click(record_student_voice, inputs=[voice_input], outputs=output_voice)
|
54 |
+
|
55 |
+
with gr.Tab("Write Comment"):
|
56 |
+
comment_input = gr.Textbox(placeholder="Your comment", label="Comment")
|
57 |
+
submit_comment = gr.Button("Submit Comment")
|
58 |
+
output_comment = gr.Textbox(label="Status")
|
59 |
+
submit_comment.click(write_comment, inputs=[comment_input], outputs=output_comment)
|
60 |
|
61 |
+
def update_question_display():
|
62 |
+
return submitted_question
|
63 |
|
64 |
+
demo.load(update_question_display, outputs=question_display)
|
65 |
|
66 |
demo.launch()
|