Skip to content

Commit 4157ede

Browse files
authored
fix: add baseURL to OpenAI initialization and correct audio file type (#299)
1 parent 15d0779 commit 4157ede

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/lib/stt/openai.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { env } from '$env/dynamic/private';
22
import { OpenAI } from 'openai';
33

4-
const openai = new OpenAI({ apiKey: env.OPENAI_API_KEY });
4+
const openai = new OpenAI({ apiKey: env.OPENAI_API_KEY, baseURL: 'https://api.openai.com/v1' });
55

66
export async function transcribe(data: Buffer): Promise<string> {
77
const transcription = await openai.audio.transcriptions.create({
88
prompt: '請將語音確實轉錄,使用的主要語言為臺灣繁體中文,次要語言為英語。',
9-
file: new File([data], 'audio.mp3', { type: 'audio/mp3' }),
9+
file: new File([data], 'audio.mp3', { type: 'audio/mpeg' }),
1010
model: 'gpt-4o-transcribe'
1111
});
1212

0 commit comments

Comments
 (0)