jinggujiwoo7 commited on
Commit
3e0f3fc
β€’
1 Parent(s): c558203

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -23
app.py CHANGED
@@ -1,39 +1,28 @@
1
  import gradio as gr
2
 
3
- # μ €μž₯된 μŒμ„± νŒŒμΌμ„ κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
4
- recordings = {}
5
- # μ €μž₯된 λŒ“κΈ€μ„ κ΄€λ¦¬ν•˜λŠ” λ”•μ…”λ„ˆλ¦¬
6
- comments = {}
7
- # μ„ μƒλ‹˜μ΄ μ œμΆœν•œ μ§ˆλ¬Έμ„ μ €μž₯ν•˜λŠ” λ³€μˆ˜
8
- submitted_question = ""
9
 
10
  # μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
11
  def teacher_question(question):
12
- global submitted_question
13
- submitted_question = question
 
14
  return question
15
 
16
  # ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
17
  def record_student_voice(voice):
18
- global submitted_question
19
- if submitted_question:
20
- if submitted_question in recordings:
21
- recordings[submitted_question].append(voice)
22
- else:
23
- recordings[submitted_question] = [voice]
24
- return "Voice recorded successfully for question: " + submitted_question
25
  else:
26
  return "Please submit a question first."
27
 
28
  # λŒ“κΈ€ μ €μž₯
29
  def write_comment(comment):
30
- global submitted_question
31
- if submitted_question:
32
- if submitted_question in comments:
33
- comments[submitted_question].append(comment)
34
- else:
35
- comments[submitted_question] = [comment]
36
- return "Comment added successfully for question: " + submitted_question
37
  else:
38
  return "Please submit a question first."
39
 
@@ -59,7 +48,7 @@ with gr.Blocks() as demo:
59
  submit_comment.click(write_comment, inputs=[comment_input], outputs=output_comment)
60
 
61
  def update_question_display():
62
- return submitted_question
63
 
64
  demo.load(update_question_display, outputs=question_display)
65
 
 
1
  import gradio as gr
2
 
3
+ # μ „μ—­ μƒνƒœλ₯Ό μœ μ§€ν•˜λŠ” λ³€μˆ˜
4
+ state = {"question": "", "recordings": {}, "comments": {}}
 
 
 
 
5
 
6
  # μ„ μƒλ‹˜μ˜ 질문 μž…λ ₯ λ°›κΈ°
7
  def teacher_question(question):
8
+ state["question"] = question
9
+ state["recordings"][question] = []
10
+ state["comments"][question] = []
11
  return question
12
 
13
  # ν•™μƒλ“€μ˜ μŒμ„± λ…ΉμŒ 및 μ €μž₯
14
  def record_student_voice(voice):
15
+ if state["question"]:
16
+ state["recordings"][state["question"]].append(voice)
17
+ return f"Voice recorded successfully for question: {state['question']}"
 
 
 
 
18
  else:
19
  return "Please submit a question first."
20
 
21
  # λŒ“κΈ€ μ €μž₯
22
  def write_comment(comment):
23
+ if state["question"]:
24
+ state["comments"][state["question"]].append(comment)
25
+ return f"Comment added successfully for question: {state['question']}"
 
 
 
 
26
  else:
27
  return "Please submit a question first."
28
 
 
48
  submit_comment.click(write_comment, inputs=[comment_input], outputs=output_comment)
49
 
50
  def update_question_display():
51
+ return state["question"]
52
 
53
  demo.load(update_question_display, outputs=question_display)
54