use managed deepgram when signed in

This commit is contained in:
Ramnique Singh 2026-03-13 22:26:17 +05:30
parent 604d521ac2
commit 7097cb064a
5 changed files with 59 additions and 66 deletions

View file

@ -33,6 +33,23 @@ export async function getVoiceConfig(): Promise<VoiceConfig> {
};
}
export async function getDeepgramToken(): Promise<{ token: string } | null> {
const signedIn = await isSignedIn();
if (!signedIn) return null;
const accessToken = await getAccessToken();
const response = await fetch(`${API_URL}/v1/voice/deepgram-token`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${accessToken}` },
});
if (!response.ok) {
console.error('[voice] Deepgram token error:', response.status);
return null;
}
const data = await response.json();
return { token: data.token };
}
export async function synthesizeSpeech(text: string): Promise<{ audioBase64: string; mimeType: string }> {
const config = await getVoiceConfig();
const signedIn = await isSignedIn();