ankban commited on
Commit
e44faea
Β·
verified Β·
1 Parent(s): 262d46c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -94,7 +94,10 @@ Transcript:
94
  # === GPT-4 Suggested Example ===
95
  def generate_example_response(transcript, language):
96
  prompt = f"""
97
- You are a communication tutor. Rewrite this speech transcript to be a more polished and confident version, while keeping the meaning and tone similar. Respond in {language}.
 
 
 
98
 
99
  Transcript:
100
  {transcript}
@@ -102,13 +105,13 @@ Transcript:
102
  response = client.chat.completions.create(
103
  model="gpt-4",
104
  messages=[
105
- {"role": "system", "content": "You are a helpful speaking coach."},
106
  {"role": "user", "content": prompt}
107
- ],
108
- temperature=0.7
109
  )
110
  return response.choices[0].message.content
111
 
 
112
  # === Main Feedback Function ===
113
  def tutor_feedback(audio_file, language):
114
  if not audio_file or not os.path.exists(audio_file):
@@ -155,7 +158,7 @@ with gr.Blocks(css="light_mode_chatter_owl.css") as app:
155
  try_again = gr.Button("πŸ” Try Again")
156
  show_example = gr.Button("🎯 Show Me an Example")
157
 
158
- example_box = gr.Textbox(label="πŸ—£ Suggested Improvement", visible=False)
159
 
160
  # Connect functions
161
  audio_input.change(
 
94
  # === GPT-4 Suggested Example ===
95
  def generate_example_response(transcript, language):
96
  prompt = f"""
97
+ You are a communication coach.
98
+
99
+ Rewrite this speech to make it more polished, fluent, and confident.
100
+ Keep the meaning and tone the same, but improve clarity and structure.
101
 
102
  Transcript:
103
  {transcript}
 
105
  response = client.chat.completions.create(
106
  model="gpt-4",
107
  messages=[
108
+ {"role": "system", "content": f"Reply in {language}. Provide only the improved version of the speech."},
109
  {"role": "user", "content": prompt}
110
+ ]
 
111
  )
112
  return response.choices[0].message.content
113
 
114
+
115
  # === Main Feedback Function ===
116
  def tutor_feedback(audio_file, language):
117
  if not audio_file or not os.path.exists(audio_file):
 
158
  try_again = gr.Button("πŸ” Try Again")
159
  show_example = gr.Button("🎯 Show Me an Example")
160
 
161
+ example_box = gr.Textbox(label="πŸ—£ Suggested Improvement", visible=True, placeholder="Click to generate improved speech...")
162
 
163
  # Connect functions
164
  audio_input.change(