jinggujiwoo7 commited on
Commit
db8c649
β€’
1 Parent(s): 67cc8de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -23
app.py CHANGED
@@ -1,52 +1,36 @@
1
  import gradio as gr
2
 
3
  # μ „μ—­ λ³€μˆ˜
4
- questions = {}
5
  recordings = {}
6
 
7
- # μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
8
- @app
9
- def submit_question(teacher_name, question):
10
- questions[teacher_name] = question
11
- return f"Question submitted successfully by {teacher_name}!"
12
-
13
  # ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
14
- @app
15
  def record_and_submit_voice(student_name, voice):
16
  recordings.setdefault(student_name, []).append(voice)
17
  return f"Voice recorded and submitted successfully by {student_name}!"
18
 
19
  # μ½”λ©˜νŠΈ μž‘μ„±
20
- @app
21
- def write_comment(student_name, teacher_name, comment):
22
- if teacher_name in questions:
23
- comment_list = questions.setdefault(teacher_name, [])
24
  comment_list.append((student_name, comment))
25
  return f"Comment added successfully by {student_name}!"
26
  else:
27
- return "No question submitted by teacher yet!"
28
 
29
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
30
  with gr.Blocks() as app:
31
- teacher_name_input = gr.Textbox(placeholder="Enter teacher's name", label="Teacher's Name")
32
- question_input = gr.Textbox(placeholder="Enter your question here...", label="Teacher's Question")
33
- submit_question_button = gr.Button("Submit Question")
34
  student_name_input = gr.Textbox(placeholder="Enter your name", label="Your Name")
35
  voice_input = gr.Audio(type="numpy", label="Record your voice")
36
  submit_voice_button = gr.Button("Submit Voice")
37
  play_recording_dropdown = gr.Dropdown(label="Select recording to play")
38
 
39
- @app
40
- def submit_question_handler():
41
- return submit_question(teacher_name_input.value, question_input.value)
42
-
43
  @app
44
  def submit_voice_handler():
45
  return record_and_submit_voice(student_name_input.value, voice_input.value)
46
 
47
  @app
48
- def play_recording_handler(selected_recording):
49
- return recordings.get(selected_recording, [])
50
 
51
  comment_input = gr.Textbox(placeholder="Write your comment here...", label="Write Comment")
52
  submit_comment_button = gr.Button("Submit Comment")
@@ -55,7 +39,6 @@ with gr.Blocks() as app:
55
  def submit_comment_handler():
56
  return write_comment(student_name_input.value, play_recording_dropdown.value, comment_input.value)
57
 
58
- submit_question_button.click(submit_question_handler)
59
  submit_voice_button.click(submit_voice_handler)
60
  submit_comment_button.click(submit_comment_handler)
61
 
 
1
  import gradio as gr
2
 
3
  # μ „μ—­ λ³€μˆ˜
 
4
  recordings = {}
5
 
 
 
 
 
 
 
6
  # ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
 
7
  def record_and_submit_voice(student_name, voice):
8
  recordings.setdefault(student_name, []).append(voice)
9
  return f"Voice recorded and submitted successfully by {student_name}!"
10
 
11
  # μ½”λ©˜νŠΈ μž‘μ„±
12
+ def write_comment(student_name, selected_student_name, comment):
13
+ if selected_student_name in recordings:
14
+ comment_list = recordings[selected_student_name]
 
15
  comment_list.append((student_name, comment))
16
  return f"Comment added successfully by {student_name}!"
17
  else:
18
+ return "Selected student's recording not found!"
19
 
20
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
21
  with gr.Blocks() as app:
 
 
 
22
  student_name_input = gr.Textbox(placeholder="Enter your name", label="Your Name")
23
  voice_input = gr.Audio(type="numpy", label="Record your voice")
24
  submit_voice_button = gr.Button("Submit Voice")
25
  play_recording_dropdown = gr.Dropdown(label="Select recording to play")
26
 
 
 
 
 
27
  @app
28
  def submit_voice_handler():
29
  return record_and_submit_voice(student_name_input.value, voice_input.value)
30
 
31
  @app
32
+ def play_recording_handler(selected_student_name):
33
+ return recordings.get(selected_student_name, [])
34
 
35
  comment_input = gr.Textbox(placeholder="Write your comment here...", label="Write Comment")
36
  submit_comment_button = gr.Button("Submit Comment")
 
39
  def submit_comment_handler():
40
  return write_comment(student_name_input.value, play_recording_dropdown.value, comment_input.value)
41
 
 
42
  submit_voice_button.click(submit_voice_handler)
43
  submit_comment_button.click(submit_comment_handler)
44