Spaces:
Running
Running
fix: add required language= arg to apply_transcription_request()
Browse files- api/main.py +5 -0
- proxy/index.js +4 -2
api/main.py
CHANGED
|
@@ -72,6 +72,7 @@ def _transcribe_sync(wav_path: str) -> str:
|
|
| 72 |
inputs = _processor.apply_transcription_request(
|
| 73 |
audio=[audio_array],
|
| 74 |
format=["WAV"],
|
|
|
|
| 75 |
model_id=MODEL_ID,
|
| 76 |
return_tensors="pt",
|
| 77 |
)
|
|
@@ -516,6 +517,10 @@ async def transcribe_diarize(audio: UploadFile = File(...)):
|
|
| 516 |
loop = asyncio.get_running_loop()
|
| 517 |
full_text = await loop.run_in_executor(None, _transcribe_sync, wav_path)
|
| 518 |
print(f"[voxtral] {req_id} STT done {(time.perf_counter()-t0)*1000:.0f}ms text_len={len(full_text)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
finally:
|
| 520 |
if wav_path and os.path.exists(wav_path):
|
| 521 |
try: os.unlink(wav_path)
|
|
|
|
| 72 |
inputs = _processor.apply_transcription_request(
|
| 73 |
audio=[audio_array],
|
| 74 |
format=["WAV"],
|
| 75 |
+
language="en",
|
| 76 |
model_id=MODEL_ID,
|
| 77 |
return_tensors="pt",
|
| 78 |
)
|
|
|
|
| 517 |
loop = asyncio.get_running_loop()
|
| 518 |
full_text = await loop.run_in_executor(None, _transcribe_sync, wav_path)
|
| 519 |
print(f"[voxtral] {req_id} STT done {(time.perf_counter()-t0)*1000:.0f}ms text_len={len(full_text)}")
|
| 520 |
+
except Exception as e:
|
| 521 |
+
import traceback as _tb
|
| 522 |
+
print(f"[voxtral] {req_id} STT error: {e}\n{_tb.format_exc()}")
|
| 523 |
+
raise HTTPException(status_code=500, detail=f"Transcription failed: {e}")
|
| 524 |
finally:
|
| 525 |
if wav_path and os.path.exists(wav_path):
|
| 526 |
try: os.unlink(wav_path)
|
proxy/index.js
CHANGED
|
@@ -90,11 +90,13 @@ async function proxyToModel(req, res, modelPath, timeoutMs) {
|
|
| 90 |
const r = await fetch(url, { method: "POST", body: form, signal: controller.signal });
|
| 91 |
clearTimeout(timeoutId);
|
| 92 |
|
| 93 |
-
const
|
|
|
|
|
|
|
| 94 |
|
| 95 |
if (!r.ok) {
|
| 96 |
const errMsg = data.detail || data.error || "Failed";
|
| 97 |
-
console.error(`[server] ${reqId} model error ${r.status}: ${errMsg}`);
|
| 98 |
return res.status(r.status >= 500 ? 502 : r.status).json({
|
| 99 |
error: typeof errMsg === "string" ? errMsg : "Model error",
|
| 100 |
});
|
|
|
|
| 90 |
const r = await fetch(url, { method: "POST", body: form, signal: controller.signal });
|
| 91 |
clearTimeout(timeoutId);
|
| 92 |
|
| 93 |
+
const rawText = await r.text().catch(() => "");
|
| 94 |
+
let data = {};
|
| 95 |
+
try { data = JSON.parse(rawText); } catch {}
|
| 96 |
|
| 97 |
if (!r.ok) {
|
| 98 |
const errMsg = data.detail || data.error || "Failed";
|
| 99 |
+
console.error(`[server] ${reqId} model error ${r.status}: ${errMsg} | raw=${rawText.slice(0, 300)}`);
|
| 100 |
return res.status(r.status >= 500 ? 502 : r.status).json({
|
| 101 |
error: typeof errMsg === "string" ? errMsg : "Model error",
|
| 102 |
});
|