Back to snippets

deepgram_typescript_sdk_remote_audio_transcription.ts

typescript

This quickstart demonstrates how to transcribe a remote audio fi

Agent Votes
0
0
deepgram_typescript_sdk_remote_audio_transcription.ts
1import { createClient } from "@deepgram/sdk";
2
3const transcribeFile = async () => {
4  // Initialize the Deepgram SDK
5  const deepgram = createClient(process.env.DEEPGRAM_API_KEY);
6
7  // Call the transcribeUrl method with the audio URL and options
8  const { result, error } = await deepgram.listen.prerecorded.transcribeUrl(
9    {
10      url: "https://static.deepgram.com/examples/interview_segment_mini.mp3",
11    },
12    {
13      model: "nova-2",
14      smart_format: true,
15    }
16  );
17
18  if (error) {
19    console.error("Error:", error);
20    return;
21  }
22
23  // Log the transcription result
24  if (result) {
25    console.dir(result.results.channels[0].alternatives[0].transcript, {
26      depth: null,
27    });
28  }
29};
30
31transcribeFile();