jinggujiwoo7
commited on
Commit
β’
f681712
1
Parent(s):
59a89e4
Update app.py
Browse files
app.py
CHANGED
@@ -1,33 +1,28 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
# μνλ₯Ό
|
4 |
-
|
5 |
-
recordings = {}
|
6 |
-
comments = {}
|
7 |
|
8 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
9 |
def teacher_question(question):
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
comments[submitted_question] = []
|
14 |
return question
|
15 |
|
16 |
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
|
17 |
def record_student_voice(voice):
|
18 |
-
|
19 |
-
|
20 |
-
|
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 |
-
|
28 |
-
|
29 |
-
|
30 |
-
return f"Comment added successfully for question: {submitted_question}"
|
31 |
else:
|
32 |
return "Please submit a question first."
|
33 |
|
@@ -40,17 +35,22 @@ with gr.Blocks() as demo:
|
|
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
|
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
|
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()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# μ μ μνλ₯Ό μ μ§νλ λ³μ
|
4 |
+
state = {"question": "", "recordings": {}, "comments": {}}
|
|
|
|
|
5 |
|
6 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
7 |
def teacher_question(question):
|
8 |
+
state["question"] = question
|
9 |
+
state["recordings"][question] = []
|
10 |
+
state["comments"][question] = []
|
|
|
11 |
return question
|
12 |
|
13 |
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
|
14 |
def record_student_voice(voice):
|
15 |
+
if state["question"]:
|
16 |
+
state["recordings"][state["question"]].append(voice)
|
17 |
+
return f"Voice recorded successfully for question: {state['question']}"
|
|
|
18 |
else:
|
19 |
return "Please submit a question first."
|
20 |
|
21 |
# λκΈ μ μ₯
|
22 |
def write_comment(comment):
|
23 |
+
if state["question"]:
|
24 |
+
state["comments"][state["question"]].append(comment)
|
25 |
+
return f"Comment added successfully for question: {state['question']}"
|
|
|
26 |
else:
|
27 |
return "Please submit a question first."
|
28 |
|
|
|
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_display = gr.Textbox(label="Question", interactive=False)
|
46 |
comment_input = gr.Textbox(placeholder="Your comment", label="Comment")
|
47 |
submit_comment = gr.Button("Submit Comment")
|
48 |
output_comment = gr.Textbox(label="Status")
|
49 |
submit_comment.click(write_comment, inputs=[comment_input], outputs=output_comment)
|
50 |
|
51 |
+
def update_question_display():
|
52 |
+
return state["question"]
|
53 |
+
|
54 |
+
demo.load(fn=update_question_display, outputs=[question_display, comment_display])
|
55 |
+
|
56 |
demo.launch()
|