jinggujiwoo7 commited on
Commit
fc94876
β€’
1 Parent(s): 57a4e23

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -23,12 +23,12 @@ def record_student_voice(student_name, question, voice):
23
 
24
  return "Voice recorded successfully!"
25
 
26
- # μ €μž₯된 μŒμ„± μž¬μƒ
27
- def play_recorded_voice(question):
28
  if question in recordings:
29
  return recordings[question]
30
  else:
31
- return ["No recordings available for this question."]
32
 
33
  # μŒμ„±μ— λŒ€ν•œ μ½”λ©˜νŠΈ μž‘μ„±
34
  def write_comment(question, comment):
@@ -54,11 +54,18 @@ record_interface = gr.Interface(
54
  title="Record Your Voice"
55
  )
56
 
57
- play_interface = gr.Interface(
58
- fn=play_recorded_voice,
59
  inputs=gr.Textbox(placeholder="Question"),
60
- outputs=gr.Audio(type="filepath", label="Recorded Voices", multiple=True),
61
- title="Play Recorded Voices"
 
 
 
 
 
 
 
62
  )
63
 
64
  comment_interface = gr.Interface(
@@ -69,4 +76,4 @@ comment_interface = gr.Interface(
69
  )
70
 
71
  # Gradio μ•± μ‹€ν–‰
72
- gr.TabbedInterface([question_interface, record_interface, play_interface, comment_interface], ["Teacher's Question", "Record Voice", "Play Voices", "Write Comment"]).launch()
 
23
 
24
  return "Voice recorded successfully!"
25
 
26
+ # μ €μž₯된 μŒμ„± λͺ©λ‘ 제곡
27
+ def get_recorded_list(question):
28
  if question in recordings:
29
  return recordings[question]
30
  else:
31
+ return []
32
 
33
  # μŒμ„±μ— λŒ€ν•œ μ½”λ©˜νŠΈ μž‘μ„±
34
  def write_comment(question, comment):
 
54
  title="Record Your Voice"
55
  )
56
 
57
+ list_interface = gr.Interface(
58
+ fn=get_recorded_list,
59
  inputs=gr.Textbox(placeholder="Question"),
60
+ outputs=gr.Dropdown(label="Select a recording to play"),
61
+ title="List Recorded Voices"
62
+ )
63
+
64
+ play_interface = gr.Interface(
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
  comment_interface = gr.Interface(
 
76
  )
77
 
78
  # Gradio μ•± μ‹€ν–‰
79
+ gr.TabbedInterface([question_interface, record_interface, list_interface, play_interface, comment_interface], ["Teacher's Question", "Record Voice", "List Voices", "Play Voice", "Write Comment"]).launch()