jinggujiwoo7 commited on
Commit
45b9570
β€’
1 Parent(s): c53ff7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
2
 
3
  # μ €μž₯된 μŒμ„± νŒŒμΌμ„ κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
4
  recordings = {}
 
 
5
 
6
  # μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
7
  def teacher_question(question):
@@ -18,6 +20,15 @@ def record_student_voice(question, voice):
18
  recordings[question] = [voice]
19
  return "Voice recorded successfully!"
20
 
 
 
 
 
 
 
 
 
 
21
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
22
  with gr.Blocks() as demo:
23
  with gr.Tab("Teacher's Question"):
@@ -27,15 +38,26 @@ with gr.Blocks() as demo:
27
  submit_question.click(teacher_question, inputs=question_input, outputs=[output_question])
28
 
29
  with gr.Tab("Record Voice"):
30
- question_display = gr.Textbox(label="Question", interactive=False)
31
  voice_input = gr.Audio(type="numpy", label="Record your voice")
32
  submit_voice = gr.Button("Submit Voice")
33
  output_voice = gr.Textbox(label="Status")
34
- submit_voice.click(record_student_voice, inputs=[question_display, voice_input], outputs=output_voice)
 
 
 
 
 
 
 
 
 
 
35
 
36
- def update_question_display(question):
37
- question_display.value = question
38
 
39
- demo.load(update_question_display, inputs=output_question)
 
40
 
41
  demo.launch()
 
2
 
3
  # μ €μž₯된 μŒμ„± νŒŒμΌμ„ κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
4
  recordings = {}
5
+ # μ €μž₯된 닡글을 κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
6
+ comments = {}
7
 
8
  # μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
9
  def teacher_question(question):
 
20
  recordings[question] = [voice]
21
  return "Voice recorded successfully!"
22
 
23
+ # λ‹΅κΈ€ μž‘μ„±
24
+ def write_comment(question, comment):
25
+ global comments
26
+ if question in comments:
27
+ comments[question].append(comment)
28
+ else:
29
+ comments[question] = [comment]
30
+ return "Comment added successfully!"
31
+
32
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
33
  with gr.Blocks() as demo:
34
  with gr.Tab("Teacher's Question"):
 
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=[question_select, voice_input], outputs=output_voice)
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 update_comment_select(question):
58
+ comment_question_input.choices = [question]
59
 
60
+ demo.load(update_question_select, inputs=output_question)
61
+ demo.load(update_comment_select, inputs=output_question)
62
 
63
  demo.launch()