jinggujiwoo7 commited on
Commit
5e95e64
β€’
1 Parent(s): 9e74d13

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ # μ €μž₯된 μŒμ„± 파일과 μ½”λ©˜νŠΈλ₯Ό κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
4
+ recordings = {}
5
+
6
+ # μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
7
+ def teacher_question():
8
+ question = input("Enter your question: ")
9
+ return question
10
+
11
+ # ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
12
+ def record_student_voice(student_name, question, voice):
13
+ # μŒμ„± 파일 μ €μž₯
14
+ file_path = f"recordings/{student_name}_{question}.wav"
15
+ os.makedirs("recordings", exist_ok=True)
16
+ with open(file_path, "wb") as f:
17
+ f.write(voice)
18
+
19
+ # μŒμ„± 파일 경둜 μ €μž₯
20
+ if question in recordings:
21
+ recordings[question].append(file_path)
22
+ else:
23
+ recordings[question] = [file_path]
24
+
25
+ return "Voice recorded successfully!"
26
+
27
+ # μ €μž₯된 μŒμ„± μž¬μƒ
28
+ def play_recorded_voice(question):
29
+ if question in recordings:
30
+ print("Available recordings:")
31
+ for index, file_path in enumerate(recordings[question], start=1):
32
+ print(f"{index}. {file_path}")
33
+ else:
34
+ print("No recordings available for this question.")
35
+
36
+ # μŒμ„±μ— λŒ€ν•œ μ½”λ©˜νŠΈ μž‘μ„±
37
+ def write_comment(question, comment):
38
+ # μ½”λ©˜νŠΈ μ €μž₯ λ“±μ˜ 좔가적인 μž‘μ—… μˆ˜ν–‰ κ°€λŠ₯
39
+ return f"Comment '{comment}' added successfully for question '{question}'."
40
+
41
+
42
+ # μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯
43
+ question = teacher_question()
44
+
45
+ # ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
46
+ student_name = input("Enter your name: ")
47
+ record_student_voice(student_name, question, b"Dummy voice data")
48
+
49
+ # μ €μž₯된 μŒμ„± μž¬μƒ
50
+ play_recorded_voice(question)
51
+
52
+ # μ½”λ©˜νŠΈ μž‘μ„±
53
+ comment = input("Write your comment: ")
54
+ write_comment(question, comment)