codingchobo / app.py
jinggujiwoo7's picture
Create app.py
5e95e64 verified
raw
history blame
1.62 kB
import os
# μ €μž₯된 μŒμ„± 파일과 μ½”λ©˜νŠΈλ₯Ό κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
recordings = {}
# μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
def teacher_question():
question = input("Enter your question: ")
return question
# ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
def record_student_voice(student_name, question, voice):
# μŒμ„± 파일 μ €μž₯
file_path = f"recordings/{student_name}_{question}.wav"
os.makedirs("recordings", exist_ok=True)
with open(file_path, "wb") as f:
f.write(voice)
# μŒμ„± 파일 경둜 μ €μž₯
if question in recordings:
recordings[question].append(file_path)
else:
recordings[question] = [file_path]
return "Voice recorded successfully!"
# μ €μž₯된 μŒμ„± μž¬μƒ
def play_recorded_voice(question):
if question in recordings:
print("Available recordings:")
for index, file_path in enumerate(recordings[question], start=1):
print(f"{index}. {file_path}")
else:
print("No recordings available for this question.")
# μŒμ„±μ— λŒ€ν•œ μ½”λ©˜νŠΈ μž‘μ„±
def write_comment(question, comment):
# μ½”λ©˜νŠΈ μ €μž₯ λ“±μ˜ 좔가적인 μž‘μ—… μˆ˜ν–‰ κ°€λŠ₯
return f"Comment '{comment}' added successfully for question '{question}'."
# μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯
question = teacher_question()
# ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
student_name = input("Enter your name: ")
record_student_voice(student_name, question, b"Dummy voice data")
# μ €μž₯된 μŒμ„± μž¬μƒ
play_recorded_voice(question)
# μ½”λ©˜νŠΈ μž‘μ„±
comment = input("Write your comment: ")
write_comment(question, comment)