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 getTranscription = async () => {
4  // Initialize the Deepgram SDK
5  const deepgram = createClient("YOUR_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_a.wav",
11    },
12    {
13      model: "nova-2",
14      smart_format: true,
15    }
16  );
17
18  if (error) {
19    console.error("Error transcribing audio:", error);
20    return;
21  }
22
23  // Log the transcription result
24  if (result) {
25    console.dir(result.results.channels[0].alternatives[0].transcript, { depth: null });
26  }
27};
28
29getTranscription();
deepgram_typescript_sdk_remote_audio_transcription.ts - Raysurfer Public Snippets