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