File size: 2,384 Bytes
7f4441c c53ff7e 1746c02 45b9570 7f4441c 5e95e64 7f4441c a8345a1 e46bb7f 5e95e64 1746c02 c53ff7e 1746c02 c53ff7e 1746c02 c53ff7e 1746c02 45b9570 7f4441c 17411ab a8345a1 17411ab 1746c02 45b9570 c53ff7e 1746c02 45b9570 17411ab 45b9570 0846800 45b9570 0846800 17411ab |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import gradio as gr
# μ μ₯λ μμ± νμΌμ κ΄λ¦¬νλ λμ
λ리
recordings = {}
# μ μ₯λ λ΅κΈμ κ΄λ¦¬νλ λμ
λ리
comments = {}
# μ μλμ μ§λ¬Έ μ
λ ₯ λ°κΈ°
def teacher_question(question):
global submitted_question
submitted_question = question
return "", question
# νμλ€μ μμ± λ
Ήμ λ° μ μ₯
def record_student_voice(question, voice):
global recordings
if question in recordings:
recordings[question].append(voice)
else:
recordings[question] = [voice]
return "Voice recorded successfully!"
# λ΅κΈ μμ±
def write_comment(question, comment):
global comments
if question in comments:
comments[question].append(comment)
else:
comments[question] = [comment]
return "Comment added successfully!"
# Gradio μΈν°νμ΄μ€ μ μ
with gr.Blocks() as demo:
with gr.Tab("Teacher's Question"):
question_input = gr.Textbox(lines=2, placeholder="Enter your question here...", label="Teacher's Question")
submit_question = gr.Button("Submit")
output_question = gr.Textbox(label="Submitted Question")
submit_question.click(teacher_question, inputs=question_input, outputs=[output_question])
with gr.Tab("Record Voice"):
question_select = gr.Dropdown(label="Select a question to record voice")
voice_input = gr.Audio(type="numpy", label="Record your voice")
submit_voice = gr.Button("Submit Voice")
output_voice = gr.Textbox(label="Status")
submit_voice.click(record_student_voice, inputs=[question_select, voice_input], outputs=output_voice)
with gr.Tab("Write Comment"):
comment_question_input = gr.Dropdown(label="Select a question to write comment")
comment_input = gr.Textbox(placeholder="Your comment", label="Comment")
submit_comment = gr.Button("Submit Comment")
output_comment = gr.Textbox(label="Status")
submit_comment.click(write_comment, inputs=[comment_question_input, comment_input], outputs=output_comment)
def update_question_select(question):
question_select.choices = [question]
def update_comment_select(question):
comment_question_input.choices = [question]
demo.load(update_question_select, inputs=output_question)
demo.load(update_comment_select, inputs=output_question)
demo.launch()
|