jinggujiwoo7
commited on
Commit
β’
17411ab
1
Parent(s):
fc94876
Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ comments = {}
|
|
7 |
|
8 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
9 |
def teacher_question(question):
|
10 |
-
return question
|
11 |
|
12 |
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
|
13 |
def record_student_voice(student_name, question, voice):
|
@@ -40,40 +40,42 @@ def write_comment(question, comment):
|
|
40 |
return f"Comment '{comment}' added successfully for question '{question}'."
|
41 |
|
42 |
# Gradio μΈν°νμ΄μ€ μ μ
|
43 |
-
|
44 |
-
|
45 |
-
inputs=gr.Textbox(lines=2, placeholder="Enter your question here...", label="Teacher's Question"),
|
46 |
-
outputs="text",
|
47 |
-
title="Teacher's Question Input"
|
48 |
-
)
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
)
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
)
|
|
|
63 |
|
64 |
-
|
65 |
-
fn=lambda file_path: file_path,
|
66 |
-
inputs=gr.Dropdown(label="Select a recording to play"),
|
67 |
-
outputs=gr.Audio(type="filepath"),
|
68 |
-
title="Play Selected Voice"
|
69 |
-
)
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
)
|
77 |
|
78 |
-
|
79 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
|
9 |
def teacher_question(question):
|
10 |
+
return question, gr.update(value=question)
|
11 |
|
12 |
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
|
13 |
def record_student_voice(student_name, question, voice):
|
|
|
40 |
return f"Comment '{comment}' added successfully for question '{question}'."
|
41 |
|
42 |
# Gradio μΈν°νμ΄μ€ μ μ
|
43 |
+
with gr.Blocks() as demo:
|
44 |
+
state_question = gr.State()
|
|
|
|
|
|
|
|
|
45 |
|
46 |
+
with gr.Tab("Teacher's Question"):
|
47 |
+
question_input = gr.Textbox(lines=2, placeholder="Enter your question here...", label="Teacher's Question")
|
48 |
+
submit_question = gr.Button("Submit")
|
49 |
+
output_question = gr.Textbox(label="Submitted Question")
|
50 |
+
submit_question.click(teacher_question, inputs=question_input, outputs=[output_question, state_question])
|
|
|
51 |
|
52 |
+
with gr.Tab("Record Voice"):
|
53 |
+
student_name_input = gr.Textbox(placeholder="Your name", label="Your name")
|
54 |
+
question_display = gr.Textbox(label="Question", interactive=False)
|
55 |
+
voice_input = gr.Audio(type="filepath", label="Record your voice")
|
56 |
+
submit_voice = gr.Button("Submit Voice")
|
57 |
+
output_voice = gr.Textbox(label="Status")
|
58 |
+
submit_voice.click(record_student_voice, inputs=[student_name_input, state_question, voice_input], outputs=output_voice)
|
59 |
|
60 |
+
gr.Textbox.update(question_display, value=state_question)
|
|
|
|
|
|
|
|
|
|
|
61 |
|
62 |
+
with gr.Tab("List Voices"):
|
63 |
+
question_list_input = gr.Textbox(placeholder="Question", label="Enter question to list recordings")
|
64 |
+
submit_list = gr.Button("Get Recordings")
|
65 |
+
recordings_list = gr.Dropdown(label="Select a recording to play")
|
66 |
+
submit_list.click(get_recorded_list, inputs=question_list_input, outputs=recordings_list)
|
|
|
67 |
|
68 |
+
with gr.Tab("Play Voice"):
|
69 |
+
recording_select = gr.Dropdown(label="Select a recording to play")
|
70 |
+
play_audio = gr.Audio(type="filepath", label="Recorded Voice")
|
71 |
+
recordings_list.change(lambda x: x, inputs=recordings_list, outputs=recording_select)
|
72 |
+
recording_select.change(lambda x: x, inputs=recording_select, outputs=play_audio)
|
73 |
+
|
74 |
+
with gr.Tab("Write Comment"):
|
75 |
+
comment_question_input = gr.Textbox(placeholder="Question", label="Question")
|
76 |
+
comment_input = gr.Textbox(placeholder="Your comment", label="Comment")
|
77 |
+
submit_comment = gr.Button("Submit Comment")
|
78 |
+
output_comment = gr.Textbox(label="Status")
|
79 |
+
submit_comment.click(write_comment, inputs=[comment_question_input, comment_input], outputs=output_comment)
|
80 |
+
|
81 |
+
demo.launch()
|