Pre-Recorded Audio Transcription

An overview of the Deepgram .NET SDK and Deepgram speech-to-text pre-recorded.

The .NET SDK implements a PreRecordedClient at the root of the Deepgram namespace that allows you to request transcripts for pre-recorded audio. To request a transcript for a pre-recorded particular audio file, you’ll use the TranscribeUrl or TranscribeFile methods.

Installing the SDK

C#
1# Install the Deepgram .NET SDK
2# https://github.com/deepgram/deepgram-dotnet-sdk
3
4dotnet add package Deepgram
5
6# Optionally, install the Deepgram Microphone package
7dotnet add package Deepgram.Microphone

Transcription Sources

Two types of sources can be provided for transcription:

UrlSource

Provides a URL to the file to transcribe.

C#
1// Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key
2var deepgramClient = ClientFactory.CreateListenRESTClient();
3
4var response = await deepgramClient.TranscribeUrl(
5 new UrlSource("https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"),
6 new PreRecordedSchema()
7 {
8 Model = "nova-3",
9 });
10
11Console.WriteLine(response);

StreamSource

Provide a stream containing the file to transcribe.

C#
1// Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key
2var deepgramClient = ClientFactory.CreateListenRESTClient();
3
4var audioData = File.ReadAllBytes(@"Bueller-Life-moves-pretty-fast.wav");
5var response = await deepgramClient.TranscribeFile(
6 audioData,
7 new PreRecordedSchema()
8 {
9 Model = "nova-3",
10 Punctuate = true,
11 });
12
13Console.WriteLine(response);

HTTP Client Timeout

For larger files, you might need to increase the default HTTP Timeout setting set to 30 seconds by default.

For TranscribeUrl, that would look like:

C#
1# 10 minute timeout: 600,000ms = 10mins
2CancellationTokenSource cancelToken = new CancellationTokenSource(600000);
3
4var response = await deepgramClient.TranscribeUrl(
5 new UrlSource("https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"),
6 new PreRecordedSchema()
7 {
8 Model = "nova-3",
9 },
10 cancelToken);

For TranscribeFile, that would look like:

C#
1# 10 minute timeout: 600,000ms = 10mins
2CancellationTokenSource cancelToken = new CancellationTokenSource(600000);
3
4var audioData = File.ReadAllBytes(@"Bueller-Life-moves-pretty-fast.wav");
5var response = await deepgramClient.TranscribeFile(
6 audioData,
7 new PreRecordedSchema()
8 {
9 Model = "nova-3",
10 Punctuate = true,
11 },
12 cancelToken);

Increasing the Timeout for Processing Larger Files

For larger files, you might need to increase the default HTTP Timeout setting, which is 300 seconds (or 5 mins).

C#
1var deepgram = new DeepgramClient(credentials);
2deepgram.SetHttpClientTimeout(TimeSpan.FromSeconds(300)); // 300 = 5 mins
Built with