fix(gateway): make voice transcription model configurable + router-compatible

- AI_VOICE_TRANSCRIPTION_MODEL config (default whisper-1) so the model can be a provider-qualified id (openrouter/openai/whisper-1) that actually has credentials through 9router/omniroute — bare whisper-1 maps to the openai provider which has none
- response_format json (not text): 9router proxies only json/verbose_json transcription responses; text returns 400
- parse text from the json response object
- prod env updated: model=openrouter/openai/whisper-1 (still needs OpenRouter STT balance — 402 until funded)
This commit is contained in:
asepharyana committed 2026-09-01 18:25:14 +07:00
1 parent 7ef86c81ca
commit c704fbf7a5
2 files changed
+12 -3

No files matched your search

@@ -30,12 +30,16 @@ export async function transcribeRecording(
const response = await openai.audio.transcriptions.create({
file: createReadStream(oggPath),
model: "whisper-1",
model: config.AI_VOICE_TRANSCRIPTION_MODEL,
// No `language` param → Whisper auto-detects (handles id/en mixed).
response_format: "text",
// `json` (not `text`): 9router/omniroute proxies only json/verbose_json
// transcription responses; `text` returns 400 through the router.
response_format: "json",
});
const text = typeof response === "string" ? response.trim() : null;
// With response_format "json", the SDK returns an object with `text`.
const text =
(typeof response === "string" ? response : response.text)?.trim() || null;
if (!text) {
logger.warn({ oggPath }, "Empty transcription result");
return null;