jinggujiwoo7 commited on
Commit
c558203
β€’
1 Parent(s): 4b559b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -8
app.py CHANGED
@@ -2,15 +2,16 @@ import gradio as gr
2
 
3
  # μ €μž₯된 μŒμ„± νŒŒμΌμ„ κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
4
  recordings = {}
5
-
6
- # μ„ μƒλ‹˜μ΄ μž…λ ₯ν•œ μ§ˆλ¬Έμ„ μ €μž₯ν•˜λŠ” λ³€μˆ˜
 
7
  submitted_question = ""
8
 
9
  # μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
10
  def teacher_question(question):
11
  global submitted_question
12
  submitted_question = question
13
- return "", question
14
 
15
  # ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
16
  def record_student_voice(voice):
@@ -24,22 +25,42 @@ def record_student_voice(voice):
24
  else:
25
  return "Please submit a question first."
26
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
28
  with gr.Blocks() as demo:
29
  with gr.Tab("Teacher's Question"):
30
  question_input = gr.Textbox(lines=2, placeholder="Enter your question here...", label="Teacher's Question")
31
  submit_question = gr.Button("Submit")
32
  output_question = gr.Textbox(label="Submitted Question")
33
- submit_question.click(teacher_question, inputs=question_input, outputs=[output_question])
34
 
35
  with gr.Tab("Record Voice"):
 
 
36
  submit_voice = gr.Button("Submit Voice")
37
  output_voice = gr.Textbox(label="Status")
38
- submit_voice.click(record_student_voice, outputs=output_voice)
 
 
 
 
 
 
39
 
40
- def update_question_display(question):
41
- output_voice.value = "Recording for question: " + question
42
 
43
- demo.load(update_question_display, inputs=output_question)
44
 
45
  demo.launch()
 
2
 
3
  # μ €μž₯된 μŒμ„± νŒŒμΌμ„ κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
4
  recordings = {}
5
+ # μ €μž₯된 λŒ“κΈ€μ„ κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
6
+ comments = {}
7
+ # μ„ μƒλ‹˜μ΄ μ œμΆœν•œ μ§ˆλ¬Έμ„ μ €μž₯ν•˜λŠ” λ³€μˆ˜
8
  submitted_question = ""
9
 
10
  # μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
11
  def teacher_question(question):
12
  global submitted_question
13
  submitted_question = question
14
+ return question
15
 
16
  # ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
17
  def record_student_voice(voice):
 
25
  else:
26
  return "Please submit a question first."
27
 
28
+ # λŒ“κΈ€ μ €μž₯
29
+ def write_comment(comment):
30
+ global submitted_question
31
+ if submitted_question:
32
+ if submitted_question in comments:
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
+
40
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
41
  with gr.Blocks() as demo:
42
  with gr.Tab("Teacher's Question"):
43
  question_input = gr.Textbox(lines=2, placeholder="Enter your question here...", label="Teacher's Question")
44
  submit_question = gr.Button("Submit")
45
  output_question = gr.Textbox(label="Submitted Question")
46
+ submit_question.click(teacher_question, inputs=question_input, outputs=output_question)
47
 
48
  with gr.Tab("Record Voice"):
49
+ question_display = gr.Textbox(label="Question", interactive=False)
50
+ voice_input = gr.Audio(type="numpy", label="Record your voice")
51
  submit_voice = gr.Button("Submit Voice")
52
  output_voice = gr.Textbox(label="Status")
53
+ submit_voice.click(record_student_voice, inputs=[voice_input], outputs=output_voice)
54
+
55
+ with gr.Tab("Write Comment"):
56
+ comment_input = gr.Textbox(placeholder="Your comment", label="Comment")
57
+ submit_comment = gr.Button("Submit Comment")
58
+ output_comment = gr.Textbox(label="Status")
59
+ submit_comment.click(write_comment, inputs=[comment_input], outputs=output_comment)
60
 
61
+ def update_question_display():
62
+ return submitted_question
63
 
64
+ demo.load(update_question_display, outputs=question_display)
65
 
66
  demo.launch()