Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| # μ μ λ³μ | |
| recordings = {} | |
| # νμλ€μ μμ± λ Ήμ λ° μ μ₯ | |
| def record_and_submit_voice(student_name, voice): | |
| recordings.setdefault(student_name, []).append(voice) | |
| return f"Voice recorded and submitted successfully by {student_name}!" | |
| # μ½λ©νΈ μμ± | |
| def write_comment(student_name, selected_student_name, comment): | |
| if selected_student_name in recordings: | |
| comment_list = recordings[selected_student_name] | |
| comment_list.append((student_name, comment)) | |
| return f"Comment added successfully by {student_name}!" | |
| else: | |
| return "Selected student's recording not found!" | |
| # Gradio μΈν°νμ΄μ€ μ μ | |
| with gr.Blocks() as app: | |
| student_name_input = gr.Textbox(placeholder="Enter your name", label="Your Name") | |
| voice_input = gr.Audio(type="numpy", label="Record your voice") | |
| submit_voice_button = gr.Button("Submit Voice") | |
| play_recording_dropdown = gr.Dropdown(label="Select recording to play") | |
| def submit_voice_handler(): | |
| return record_and_submit_voice(student_name_input.value, voice_input.value) | |
| def play_recording_handler(selected_student_name): | |
| return recordings.get(selected_student_name, []) | |
| comment_input = gr.Textbox(placeholder="Write your comment here...", label="Write Comment") | |
| submit_comment_button = gr.Button("Submit Comment") | |
| def submit_comment_handler(): | |
| return write_comment(student_name_input.value, play_recording_dropdown.value, comment_input.value) | |
| submit_voice_button.click(submit_voice_handler) | |
| submit_comment_button.click(submit_comment_handler) | |
| # μΈν°νμ΄μ€ μ€ν | |
| app.launch() | |