jinggujiwoo7
commited on
Commit
β’
5e95e64
1
Parent(s):
9e74d13
Create app.py
Browse files
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)
|