Vadym Myroshnyk commited on
Commit
bdaf791
·
1 Parent(s): 158b097
app.py CHANGED
@@ -5,6 +5,7 @@ import gradio as gr
5
  from custom_theme import CustomMinimalTheme
6
  from service.oral.oral_service import oral_exercise
7
  from service.written.written_service import written_exercise
 
8
 
9
  if os.getenv("HF_SPACE_ID") is None:
10
  from dotenv import load_dotenv
@@ -22,18 +23,19 @@ auth_credentials = [(username, password)]
22
  with gr.Blocks(theme=CustomMinimalTheme()) as demo:
23
  with gr.Tabs():
24
  with gr.TabItem("🗣️ Oral Quiz"):
25
- oral_exercise("data/oral_quiz/audio", "data/oral_quiz/expected_result")
 
26
 
27
  with gr.TabItem("✍️ Transcription Exercise"):
28
  written_exercise("data/transcription_exercise/audio",
29
- "data/transcription_exercise/expected_result")
30
 
31
  # with gr.TabItem("🗣️ Oral Gap-fill Exercise"):
32
  # oral_exercise("data/oral_gap_fill_exercise/audio",
33
  # "data/oral_gap_fill_exercise/expected_result")
34
 
35
  with gr.TabItem("🗣️ Q&A Drill"):
36
- oral_exercise("data/q&a_drill/audio", "data/q&a_drill/expected_result")
37
 
38
  if __name__ == "__main__":
39
  demo.launch(show_api=False)
 
5
  from custom_theme import CustomMinimalTheme
6
  from service.oral.oral_service import oral_exercise
7
  from service.written.written_service import written_exercise
8
+ from utils.instructions import ORAL_QUIZ, TRANSCRIPTION_EXERCISE, QA_DRILL
9
 
10
  if os.getenv("HF_SPACE_ID") is None:
11
  from dotenv import load_dotenv
 
23
  with gr.Blocks(theme=CustomMinimalTheme()) as demo:
24
  with gr.Tabs():
25
  with gr.TabItem("🗣️ Oral Quiz"):
26
+ oral_exercise(
27
+ "data/oral_quiz/audio", "data/oral_quiz/expected_result", ORAL_QUIZ)
28
 
29
  with gr.TabItem("✍️ Transcription Exercise"):
30
  written_exercise("data/transcription_exercise/audio",
31
+ "data/transcription_exercise/expected_result", TRANSCRIPTION_EXERCISE)
32
 
33
  # with gr.TabItem("🗣️ Oral Gap-fill Exercise"):
34
  # oral_exercise("data/oral_gap_fill_exercise/audio",
35
  # "data/oral_gap_fill_exercise/expected_result")
36
 
37
  with gr.TabItem("🗣️ Q&A Drill"):
38
+ oral_exercise("data/q&a_drill/audio", "data/q&a_drill/expected_result", QA_DRILL)
39
 
40
  if __name__ == "__main__":
41
  demo.launch(show_api=False)
service/oral/oral_service.py CHANGED
@@ -7,7 +7,7 @@ from utils.comparator import highlight_fuzzy_diff, get_feedback
7
  from utils.dialogue_loader import load_dialogue_lines
8
 
9
 
10
- def oral_exercise(audio_dir: str, expected_result_dir: str):
11
  audio_structure = get_audio_structure(audio_dir)
12
  week_options = list(audio_structure.keys())
13
  default_week = week_options[0]
@@ -19,22 +19,7 @@ def oral_exercise(audio_dir: str, expected_result_dir: str):
19
  with gr.Row():
20
  with gr.Column(scale=1):
21
  with gr.Accordion("📘 Instructions", open=False):
22
- gr.Markdown("""
23
- ## 🗣️ Oral Gap-fill Exercise Instructions
24
-
25
- **1.** ▶️ Start the recording and listen to the **first sentence**.
26
- **2.** ⏸️ Stop and anser the sentence **out loud**.
27
- **3.** 🎤 Record your version.
28
- **4.** 🧠 The system will transcribe your speech and compare it to the original.
29
- **5.** 🔁 Repeat steps for each sentence.
30
-
31
- ---
32
-
33
- ### 🔎 Scoring Guide
34
-
35
- 🟩 **Correct words**
36
- 🟥 **Missing / incorrect words**
37
- """)
38
  week_dropdown = gr.Dropdown(label="Select a week", choices=week_options, value=default_week)
39
 
40
  with gr.Column(scale=2):
 
7
  from utils.dialogue_loader import load_dialogue_lines
8
 
9
 
10
+ def oral_exercise(audio_dir: str, expected_result_dir: str, instruction: str):
11
  audio_structure = get_audio_structure(audio_dir)
12
  week_options = list(audio_structure.keys())
13
  default_week = week_options[0]
 
19
  with gr.Row():
20
  with gr.Column(scale=1):
21
  with gr.Accordion("📘 Instructions", open=False):
22
+ gr.Markdown(instruction)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  week_dropdown = gr.Dropdown(label="Select a week", choices=week_options, value=default_week)
24
 
25
  with gr.Column(scale=2):
service/written/written_service.py CHANGED
@@ -5,7 +5,7 @@ from utils.comparator import highlight_fuzzy_diff, get_feedback
5
  from utils.dialogue_loader import load_dialogue_lines
6
 
7
 
8
- def written_exercise(audio_dir: str, expected_result_dir: str):
9
  audio_structure = get_audio_structure(audio_dir)
10
  week_options = list(audio_structure.keys())
11
  default_week = week_options[0]
@@ -17,22 +17,7 @@ def written_exercise(audio_dir: str, expected_result_dir: str):
17
  with gr.Row():
18
  with gr.Column(scale=1):
19
  with gr.Accordion("📘 Instructions", open=False):
20
- gr.Markdown("""
21
- ## 🗣️ Transcription Practice Instructions
22
-
23
- **1.** 🎧 Listen to the whole conversation once.
24
- **2.** ▶️ Start the recording again and listen to the **first sentence**.
25
- **3.** ⏸️ Stop the recording.
26
- **4.** ✍️ Write down what you remember.
27
- **5.** 🔁 Go back and listen again to the **same sentence** and add the missing details.
28
- **6.** ⏭️ Move on to the next sentence and repeat steps 3 - 5.
29
- **7.** Be careful with spelling and punctuation.
30
-
31
- ---
32
- ### 🔎 Scoring Guide
33
- 🟩 **Correct words**
34
- 🟥 **Missing / incorrect words**
35
- """)
36
  week_dropdown = gr.Dropdown(label="Select a week", choices=week_options, value=default_week)
37
 
38
  with gr.Column(scale=2):
 
5
  from utils.dialogue_loader import load_dialogue_lines
6
 
7
 
8
+ def written_exercise(audio_dir: str, expected_result_dir: str, instruction: str):
9
  audio_structure = get_audio_structure(audio_dir)
10
  week_options = list(audio_structure.keys())
11
  default_week = week_options[0]
 
17
  with gr.Row():
18
  with gr.Column(scale=1):
19
  with gr.Accordion("📘 Instructions", open=False):
20
+ gr.Markdown(instruction)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  week_dropdown = gr.Dropdown(label="Select a week", choices=week_options, value=default_week)
22
 
23
  with gr.Column(scale=2):
utils/instructions.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ORAL_QUIZ = """
2
+ **1.** ▶️ Start the recording and listen to the **instructions** for the exercise.
3
+ **2.** 🎧 Listen to **sentence Number 1**.
4
+ **3.** 💬 Formulate your answer **out loud** without stopping the recording.
5
+ **4.** 🔊 Listen to the **recorded correct answer**.
6
+ **5.** ⏹️ Stop the recording.
7
+ **6.** 🎙️ Click **RECORD** and repeat the correct answer.
8
+ **7.** ⏹️ Click **STOP** when finished.
9
+ **8.** 🧠 Click **TRANSCRIBE** to see what the system heard.
10
+ **9.** 🔁 Repeat steps 6–8 until you are satisfied with your recording.
11
+ **10.** ✅ Click **CHECK** to compare your answer with the correct one.
12
+ **11.** 📖 Click **VIEW ALL CORRECT OPTIONS** to see all valid answers.
13
+ **12.** 🔜 Click **NEXT** and repeat the above steps for sentences **2 to 15**.
14
+
15
+ ---
16
+
17
+ ### 🔎 Scoring Guide
18
+
19
+ 🟩 **Correct words**
20
+ 🟥 **Missing / incorrect words**
21
+ """
22
+
23
+ TRANSCRIPTION_EXERCISE = """
24
+ **1.** ▶️ Start the recording and **listen to the full conversation once**.
25
+ **2.** ⏪ Go back to the **start of the conversation**.
26
+ **3.** 🎧 Listen to the **first line**.
27
+ **4.** ✍️ Stop the recording and **type what you heard**.
28
+ **5.** 🔁 Repeat steps 3 and 4 until you're **satisfied with your transcription** of the first line.
29
+ **6.** ✅ Click **CHECK** to compare your transcription with the **correct sentence**.
30
+ **7.** 🔜 Click **NEXT** and repeat the above steps for **all remaining lines**.
31
+
32
+ ---
33
+
34
+ ### 🔎 Scoring Guide
35
+
36
+ 🟩 **Correct words**
37
+ 🟥 **Missing / incorrect words**
38
+ """
39
+
40
+ QA_DRILL = """
41
+ **1.** ▶️ Start the recording and **listen to the instructions** for the exercise.
42
+ **2.** 🎧 Listen to **Question 1**.
43
+ **3.** 💬 Formulate your **answer out loud** without stopping the recording.
44
+ **4.** 🎯 Listen to the **recorded correct answer**.
45
+ **5.** ⏹️ Stop the recording.
46
+ **6.** 🔴 Click the **RECORD** button and **repeat** the recorded correct answer.
47
+ **7.** ⏹️ Click **STOP**.
48
+ **8.** 🧠 Click **TRANSCRIBE** to see what the system understood.
49
+ **9.** 🔁 Repeat steps 5 to 7 until you're **satisfied** with your recording.
50
+ **10.** ✅ Click **CHECK** to compare your answer with the correct one.
51
+ **11.** 📖 Click **VIEW ALL CORRECT OPTIONS**.
52
+ **12.** 🔜 Click **NEXT** and repeat the steps for **Questions 2 to 10**.
53
+
54
+ ---
55
+
56
+ ### 🔎 Scoring Guide
57
+
58
+ 🟩 **Correct words**
59
+ 🟥 **Missing / incorrect words**
60
+ """