ankban commited on
Commit
f4b05fc
Β·
verified Β·
1 Parent(s): 3469f82

Update spoken_module.py

Browse files
Files changed (1) hide show
  1. spoken_module.py +8 -12
spoken_module.py CHANGED
@@ -20,16 +20,12 @@ def generate_feedback(transcript, language, goal="general improvement", focus_ar
20
 
21
  prompt = f"""
22
  You are a supportive communication coach helping a learner whose goal is: **{goal}**.
23
-
24
  Evaluate the user's current speech based on the following areas:
25
  {focus_str}
26
-
27
- Give a score out of 10 and a short explanation for each area.
28
-
29
  Then provide:
30
- - A summary of strengths and improvement areas.
31
- - One motivational line to end with.
32
-
33
  Transcript:
34
  {transcript}
35
  {history_section}
@@ -48,7 +44,6 @@ Transcript:
48
  def generate_example_response(transcript, language):
49
  prompt = f"""Rewrite this speech to make it more polished, fluent, and confident.
50
  Keep the meaning and tone the same, but improve clarity and structure.
51
-
52
  Transcript:
53
  {transcript}
54
  """
@@ -73,7 +68,7 @@ def spoken_dashboard(nickname_input):
73
  gr.Markdown("""
74
  <div id="header" style="text-align: center;">
75
  <h2>πŸ¦‰ Meet <strong>Chatter the Owl</strong></h2>
76
- <p>Speak and improve your communication with personalized feedback and progress tracking.</p>
77
  </div>
78
  """)
79
 
@@ -105,7 +100,7 @@ def spoken_dashboard(nickname_input):
105
  return "", "No audio received.", None, "", [], render_empty_chart("πŸ“Š Score Comparison"), render_empty_chart("πŸ“ˆ Tone Progress"), gr.update(visible=False)
106
 
107
  if hasattr(nickname, "value"):
108
- nickname = nickname.value # Handle gr.Textbox or gr.State
109
 
110
  wav_path = convert_to_wav(audio_file)
111
  transcript = transcribe_audio(wav_path)
@@ -124,7 +119,8 @@ def spoken_dashboard(nickname_input):
124
  milestone = f"πŸŽ‰ Congrats on completing **{session_count} sessions**!"
125
  feedback_text += f"\n\n{milestone}"
126
 
127
- tts = gTTS(feedback_text, lang=LANG_CODES.get(language, "en"))
 
128
  mp3_path = f"/tmp/{uuid.uuid4()}.mp3"
129
  tts.save(mp3_path)
130
 
@@ -153,4 +149,4 @@ def spoken_dashboard(nickname_input):
153
  inputs=[hidden_transcript, language_dropdown],
154
  outputs=example_box)
155
 
156
- return spoken_panel
 
20
 
21
  prompt = f"""
22
  You are a supportive communication coach helping a learner whose goal is: **{goal}**.
 
23
  Evaluate the user's current speech based on the following areas:
24
  {focus_str}
25
+ Give a score out of 10 and a short explanation for each area. Ensure they are well formatted.
 
 
26
  Then provide:
27
+ - A detailed summary of strengths and improvement areas.
28
+ - One motivational line to end with. Do not specifically add motivational keyword, just add the line.
 
29
  Transcript:
30
  {transcript}
31
  {history_section}
 
44
  def generate_example_response(transcript, language):
45
  prompt = f"""Rewrite this speech to make it more polished, fluent, and confident.
46
  Keep the meaning and tone the same, but improve clarity and structure.
 
47
  Transcript:
48
  {transcript}
49
  """
 
68
  gr.Markdown("""
69
  <div id="header" style="text-align: center;">
70
  <h2>πŸ¦‰ Meet <strong>Chatter the Owl</strong></h2>
71
+ <p>Speak in your chosen language and get personalized feedback and progress tracking.</p>
72
  </div>
73
  """)
74
 
 
100
  return "", "No audio received.", None, "", [], render_empty_chart("πŸ“Š Score Comparison"), render_empty_chart("πŸ“ˆ Tone Progress"), gr.update(visible=False)
101
 
102
  if hasattr(nickname, "value"):
103
+ nickname = nickname.value
104
 
105
  wav_path = convert_to_wav(audio_file)
106
  transcript = transcribe_audio(wav_path)
 
119
  milestone = f"πŸŽ‰ Congrats on completing **{session_count} sessions**!"
120
  feedback_text += f"\n\n{milestone}"
121
 
122
+ lang_code = LANG_CODES.get(language, "en")
123
+ tts = gTTS(feedback_text, lang=lang_code)
124
  mp3_path = f"/tmp/{uuid.uuid4()}.mp3"
125
  tts.save(mp3_path)
126
 
 
149
  inputs=[hidden_transcript, language_dropdown],
150
  outputs=example_box)
151
 
152
+ return spoken_panel