Correcting the speech-to-text output

This commit is contained in:
2026-09-22 12:24:53 +03:30
parent 75a73559b5
commit 58c3e25db6
3 changed files with 16 additions and 4 deletions
+8 -2
View File
@@ -51,9 +51,15 @@ export class AiSttService {
body: form,
signal: AbortSignal.timeout(timeoutMs),
});
} catch {
} catch (e) {
const name = e instanceof Error ? e.name : '';
if (name === 'TimeoutError' || name === 'AbortError') {
throw new ServiceUnavailableException(
'زمان تبدیل صوت تمام شد. اگر تازه مدل عوض شده، چند دقیقه صبر کنید تا دانلود شود و دوباره امتحان کنید.',
);
}
throw new ServiceUnavailableException(
'سرویس تبدیل صوت در دسترس نیست. Pipecat STT را اجرا کنید.',
'سرویس تبدیل صوت خاموش است. مدل medium معمولاً حافظهٔ سرور را پر می‌کند و پروسه را می‌کشد. در apps/stt/.env مقدار STT_MODEL=small بگذارید و pm2 restart mento-stt بزنید.',
);
}
+7 -1
View File
@@ -97,7 +97,13 @@ def _get_model() -> WhisperModel:
compute = _env("STT_COMPUTE_TYPE", "int8") or "int8"
logger.info("Loading Faster-Whisper model=%s device=%s compute=%s", name, device, compute)
try:
loaded = WhisperModel(name, device=device, compute_type=compute)
loaded = WhisperModel(
name,
device=device,
compute_type=compute,
cpu_threads=2,
num_workers=1,
)
except Exception as exc:
_model_error = str(exc)
logger.exception("Whisper model load failed")
+1 -1
View File
@@ -29,7 +29,7 @@ module.exports = {
interpreter: "none",
instances: 1,
exec_mode: "fork",
max_memory_restart: "500M",
max_memory_restart: "1500M",
time: true,
},
],