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