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:
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({
|
const response = await openai.audio.transcriptions.create({
|
||||||
file: createReadStream(oggPath),
|
file: createReadStream(oggPath),
|
||||||
model: "whisper-1",
|
model: config.AI_VOICE_TRANSCRIPTION_MODEL,
|
||||||
// No `language` param → Whisper auto-detects (handles id/en mixed).
|
// 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) {
|
if (!text) {
|
||||||
logger.warn({ oggPath }, "Empty transcription result");
|
logger.warn({ oggPath }, "Empty transcription result");
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -340,6 +340,11 @@ export const configSchema = z
|
|||||||
.optional()
|
.optional()
|
||||||
.transform((v) => v === "true")
|
.transform((v) => v === "true")
|
||||||
.default(false),
|
.default(false),
|
||||||
|
// Whisper model routed through the LLM base URL. Through 9router/omniroute
|
||||||
|
// use a provider-qualified id that has credentials (e.g.
|
||||||
|
// openrouter/openai/whisper-1) — bare `whisper-1` maps to the `openai`
|
||||||
|
// provider which the router rejects with "No credentials for provider".
|
||||||
|
AI_VOICE_TRANSCRIPTION_MODEL: z.string().default("whisper-1"),
|
||||||
|
|
||||||
// ── Auto Delete ─────────────────────────────────────────────────────
|
// ── Auto Delete ─────────────────────────────────────────────────────
|
||||||
AUTO_DELETE_FLAGGED_ENABLED: z
|
AUTO_DELETE_FLAGGED_ENABLED: z
|
||||||
|
|||||||
Reference in new issue
Block a user