diff --git a/packages/core/src/content/url.ts b/packages/core/src/content/url.ts index b775df91..7c55ffda 100644 --- a/packages/core/src/content/url.ts +++ b/packages/core/src/content/url.ts @@ -73,7 +73,7 @@ export function extractYouTubeVideoId(rawUrl: string): string | null { } export function isDirectMediaUrl(url: string): boolean { - return /\.(mp4|mov|m4v|mkv|webm|mp3|m4a|wav|flac|aac)(\?|#|$)/i.test(url) + return /\.(mp4|mov|m4v|mkv|webm|mpeg|mpg|avi|wmv|flv|mp3|m4a|wav|flac|aac|ogg|opus|aiff|wma)(\?|#|$)/i.test(url) } export function shouldPreferUrlMode(url: string): boolean { diff --git a/packages/core/src/transcription/whisper/openai.ts b/packages/core/src/transcription/whisper/openai.ts index 6ef1d72b..2acc8536 100644 --- a/packages/core/src/transcription/whisper/openai.ts +++ b/packages/core/src/transcription/whisper/openai.ts @@ -5,7 +5,8 @@ export async function transcribeWithOpenAi( bytes: Uint8Array, mediaType: string, filename: string | null, - apiKey: string + apiKey: string, + baseUrl?: string | null ): Promise { const form = new FormData() const providedName = filename?.trim() ? filename.trim() : 'media' @@ -14,7 +15,14 @@ export async function transcribeWithOpenAi( form.append('file', new Blob([toArrayBuffer(bytes)], { type: mediaType }), safeName) form.append('model', 'whisper-1') - const response = await globalThis.fetch('https://api.openai.com/v1/audio/transcriptions', { + // Support custom OpenAI-compatible whisper endpoints via OPENAI_WHISPER_BASE_URL or OPENAI_BASE_URL + const effectiveBaseUrl = baseUrl + ?? process.env.OPENAI_WHISPER_BASE_URL + ?? process.env.OPENAI_BASE_URL + ?? 'https://api.openai.com/v1' + const transcriptionUrl = `${effectiveBaseUrl.replace(/\/+$/, '')}/audio/transcriptions` + + const response = await globalThis.fetch(transcriptionUrl, { method: 'POST', headers: { Authorization: `Bearer ${apiKey}` }, body: form,