Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 β
|
| 193 |
if audio_path is None:
|
| 194 |
return gr.update(visible=False), _err("No audio recorded.")
|
| 195 |
try:
|
| 196 |
-
import
|
| 197 |
global _whisper_model
|
| 198 |
if _whisper_model is None:
|
| 199 |
-
_whisper_model =
|
| 200 |
-
|
| 201 |
-
text
|
| 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)
|