jinggujiwoo7
commited on
Commit
β’
cbfbd5b
1
Parent(s):
45b9570
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
#
|
4 |
-
|
5 |
-
# μ μ₯λ λ΅κΈμ κ΄λ¦¬νλ λμ
λ리
|
6 |
-
comments = {}
|
7 |
|
8 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
9 |
def teacher_question(question):
|
@@ -12,22 +10,23 @@ def teacher_question(question):
|
|
12 |
return "", question
|
13 |
|
14 |
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
|
15 |
-
def record_student_voice(
|
16 |
-
global
|
17 |
-
if
|
18 |
-
recordings
|
|
|
|
|
|
|
|
|
19 |
else:
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
if question in comments:
|
27 |
-
comments[question].append(comment)
|
28 |
else:
|
29 |
-
|
30 |
-
return "Comment added successfully!"
|
31 |
|
32 |
# Gradio μΈν°νμ΄μ€ μ μ
|
33 |
with gr.Blocks() as demo:
|
@@ -38,26 +37,14 @@ with gr.Blocks() as demo:
|
|
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=[
|
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
|
58 |
-
|
59 |
|
60 |
-
demo.load(
|
61 |
-
demo.load(update_comment_select, inputs=output_question)
|
62 |
|
63 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# μ μλμ΄ μ
λ ₯ν μ§λ¬Έμ μ μ₯νλ λ³μ
|
4 |
+
submitted_question = ""
|
|
|
|
|
5 |
|
6 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
7 |
def teacher_question(question):
|
|
|
10 |
return "", question
|
11 |
|
12 |
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
|
13 |
+
def record_student_voice(voice):
|
14 |
+
global submitted_question
|
15 |
+
if submitted_question:
|
16 |
+
if submitted_question in recordings:
|
17 |
+
recordings[submitted_question].append(voice)
|
18 |
+
else:
|
19 |
+
recordings[submitted_question] = [voice]
|
20 |
+
return "Voice recorded successfully for question: " + submitted_question
|
21 |
else:
|
22 |
+
return "Please submit a question first."
|
23 |
+
|
24 |
+
# μ μ₯λ μμ± λͺ©λ‘ μ 곡
|
25 |
+
def get_recorded_list(question):
|
26 |
+
if question in recordings:
|
27 |
+
return recordings[question]
|
|
|
|
|
28 |
else:
|
29 |
+
return []
|
|
|
30 |
|
31 |
# Gradio μΈν°νμ΄μ€ μ μ
|
32 |
with gr.Blocks() as demo:
|
|
|
37 |
submit_question.click(teacher_question, inputs=question_input, outputs=[output_question])
|
38 |
|
39 |
with gr.Tab("Record Voice"):
|
|
|
40 |
voice_input = gr.Audio(type="numpy", label="Record your voice")
|
41 |
submit_voice = gr.Button("Submit Voice")
|
42 |
output_voice = gr.Textbox(label="Status")
|
43 |
+
submit_voice.click(record_student_voice, inputs=[voice_input], outputs=output_voice)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
+
def update_question_display(question):
|
46 |
+
output_voice.value = "Recording for question: " + question
|
47 |
|
48 |
+
demo.load(update_question_display, inputs=output_question)
|
|
|
49 |
|
50 |
demo.launch()
|