fix dgm api key location

This commit is contained in:
Arjun 2026-02-02 23:11:11 +05:30
parent 158d90f415
commit 3542f10a6c

View file

@ -149,15 +149,15 @@ async function transcribeWithDeepgram(audioBlob: Blob): Promise<string | null> {
path: 'config/deepgram.json', path: 'config/deepgram.json',
encoding: 'utf8', encoding: 'utf8',
}) })
const { api_key } = JSON.parse(configResult.data) as { api_key: string } const { apiKey } = JSON.parse(configResult.data) as { apiKey: string }
if (!api_key) throw new Error('No api_key in deepgram.json') if (!apiKey) throw new Error('No apiKey in deepgram.json')
const response = await fetch( const response = await fetch(
'https://api.deepgram.com/v1/listen?model=nova-2&smart_format=true', 'https://api.deepgram.com/v1/listen?model=nova-2&smart_format=true',
{ {
method: 'POST', method: 'POST',
headers: { headers: {
Authorization: `Token ${api_key}`, Authorization: `Token ${apiKey}`,
'Content-Type': audioBlob.type, 'Content-Type': audioBlob.type,
}, },
body: audioBlob, body: audioBlob,
@ -167,7 +167,8 @@ async function transcribeWithDeepgram(audioBlob: Blob): Promise<string | null> {
if (!response.ok) throw new Error(`Deepgram API error: ${response.status}`) if (!response.ok) throw new Error(`Deepgram API error: ${response.status}`)
const result = await response.json() const result = await response.json()
return result.results?.channels?.[0]?.alternatives?.[0]?.transcript ?? null return result.results?.channels?.[0]?.alternatives?.[0]?.transcript ?? null
} catch { } catch (err) {
console.error('Deepgram transcription failed:', err)
return null return null
} }
} }