Skip to content

Commit 2c49c7d

Browse files
committed
Switch Deepgram transcription to file upload
1 parent 7981751 commit 2c49c7d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

apps/web/workflows/transcribe.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,19 @@ async function extractAudio(
197197
async function transcribeWithDeepgram(audioUrl: string): Promise<string> {
198198
"use step";
199199

200-
const audioCheckResponse = await fetch(audioUrl, {
201-
method: "HEAD",
202-
});
203-
if (!audioCheckResponse.ok) {
200+
const audioResponse = await fetch(audioUrl);
201+
if (!audioResponse.ok) {
204202
throw new Error(
205-
`Audio URL not accessible: ${audioCheckResponse.status} ${audioCheckResponse.statusText}`,
203+
`Audio URL not accessible: ${audioResponse.status} ${audioResponse.statusText}`,
206204
);
207205
}
208206

207+
const audioBuffer = Buffer.from(await audioResponse.arrayBuffer());
208+
209209
const deepgram = createClient(serverEnv().DEEPGRAM_API_KEY as string);
210210

211-
const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
212-
{ url: audioUrl },
211+
const { result, error } = await deepgram.listen.prerecorded.transcribeFile(
212+
audioBuffer,
213213
{
214214
model: "nova-3",
215215
smart_format: true,

0 commit comments

Comments
 (0)