File size: 1,523 Bytes
5e95e64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
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)