jinggujiwoo7
commited on
Commit
β’
3e0f3fc
1
Parent(s):
c558203
Update app.py
Browse files
app.py
CHANGED
@@ -1,39 +1,28 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
# μ μ₯λ λκΈμ κ΄λ¦¬νλ λμ
λ리
|
6 |
-
comments = {}
|
7 |
-
# μ μλμ΄ μ μΆν μ§λ¬Έμ μ μ₯νλ λ³μ
|
8 |
-
submitted_question = ""
|
9 |
|
10 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
11 |
def teacher_question(question):
|
12 |
-
|
13 |
-
|
|
|
14 |
return question
|
15 |
|
16 |
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
|
17 |
def record_student_voice(voice):
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
recordings[submitted_question].append(voice)
|
22 |
-
else:
|
23 |
-
recordings[submitted_question] = [voice]
|
24 |
-
return "Voice recorded successfully for question: " + submitted_question
|
25 |
else:
|
26 |
return "Please submit a question first."
|
27 |
|
28 |
# λκΈ μ μ₯
|
29 |
def write_comment(comment):
|
30 |
-
|
31 |
-
|
32 |
-
|
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 |
|
@@ -59,7 +48,7 @@ with gr.Blocks() as demo:
|
|
59 |
submit_comment.click(write_comment, inputs=[comment_input], outputs=output_comment)
|
60 |
|
61 |
def update_question_display():
|
62 |
-
return
|
63 |
|
64 |
demo.load(update_question_display, outputs=question_display)
|
65 |
|
|
|
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 |
|
|
|
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 |
|