Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
|
| 21 |
-
|
| 22 |
-
|
| 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 "
|
| 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(
|
| 49 |
-
return recordings.get(
|
| 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 |
|