eraz3r commited on
Commit
04c3719
Β·
verified Β·
1 Parent(s): 523b781

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -189,16 +189,16 @@ def handle_parse_text(task_text, user_id):
189
 
190
 
191
  def handle_transcribe_voice(audio_path, user_id):
192
- """Whisper transcription then Groq parse β€” same pipeline as notebook."""
193
  if audio_path is None:
194
  return gr.update(visible=False), _err("No audio recorded.")
195
  try:
196
- import whisper
197
  global _whisper_model
198
  if _whisper_model is None:
199
- _whisper_model = whisper.load_model("small")
200
- result = _whisper_model.transcribe(audio_path)
201
- text = result["text"].strip()
202
  return gr.update(visible=True, value=text), _ok(f'Transcribed: "{text[:60]}..."')
203
  except Exception as e:
204
  return gr.update(visible=False), _err(f"Transcription error: {e}")
@@ -1083,4 +1083,4 @@ with gr.Blocks(css=CSS, title="🧠 Second Brain") as demo:
1083
  # ── Launch ─────────────────────────────────────────────────────────────────────
1084
 
1085
  if __name__ == "__main__":
1086
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
189
 
190
 
191
  def handle_transcribe_voice(audio_path, user_id):
192
+ """Whisper transcription then Groq parse β€” uses faster-whisper for Python 3.13 compatibility."""
193
  if audio_path is None:
194
  return gr.update(visible=False), _err("No audio recorded.")
195
  try:
196
+ from faster_whisper import WhisperModel
197
  global _whisper_model
198
  if _whisper_model is None:
199
+ _whisper_model = WhisperModel("small", device="cpu", compute_type="int8")
200
+ segments, _ = _whisper_model.transcribe(audio_path)
201
+ text = " ".join(seg.text for seg in segments).strip()
202
  return gr.update(visible=True, value=text), _ok(f'Transcribed: "{text[:60]}..."')
203
  except Exception as e:
204
  return gr.update(visible=False), _err(f"Transcription error: {e}")
 
1083
  # ── Launch ─────────────────────────────────────────────────────────────────────
1084
 
1085
  if __name__ == "__main__":
1086
+ demo.launch(server_name="0.0.0.0", server_port=7860)