Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/src/content/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/transcription/whisper/openai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export async function transcribeWithOpenAi(
bytes: Uint8Array,
mediaType: string,
filename: string | null,
apiKey: string
apiKey: string,
baseUrl?: string | null
): Promise<string | null> {
const form = new FormData()
const providedName = filename?.trim() ? filename.trim() : 'media'
Expand All @@ -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,
Expand Down