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.

Transcription Sources

Two types of sources can be provided for transcription:

UrlSource

Provides a URL to the file to transcribe.

// Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key
var deepgramClient = new PreRecordedClient();

var response = await deepgramClient.TranscribeUrl(
  new UrlSource("https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"),
  new PrerecordedSchema()
  {
    Model = "nova-2",
  });

Console.WriteLine(response);

StreamSource

Provide a stream containing the file to transcribe.

// Set "DEEPGRAM_API_KEY" environment variable to your Deepgram API Key
var deepgramClient = new PreRecordedClient();

var audioData = File.ReadAllBytes(@"Bueller-Life-moves-pretty-fast.wav");
var response = await deepgramClient.TranscribeFile(
  audioData,
  new PrerecordedSchema()
  {
    Model = "nova-2",
    Punctuate = true,
  });

Console.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:

# 10 minute timeout: 600,000ms = 10mins
CancellationTokenSource cancelToken = new CancellationTokenSource(600000);

var response = await deepgramClient.TranscribeUrl(
  new UrlSource("https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"),
  new PrerecordedSchema()
  {
    Model = "nova-2",
  },
	cancelToken);

For TranscribeFile, that would look like:

# 10 minute timeout: 600,000ms = 10mins
CancellationTokenSource cancelToken = new CancellationTokenSource(600000);

var audioData = File.ReadAllBytes(@"Bueller-Life-moves-pretty-fast.wav");
var response = await deepgramClient.TranscribeFile(
  audioData,
  new PrerecordedSchema()
  {
    Model = "nova-2",
    Punctuate = true,
  },
	cancelToken);

For larger files you might need to increase the default HTTP Timeout setting which is 100 seconds

var deepgram = new DeepgramClient(credentials);
deepgram.SetHttpClientTimeout(TimeSpan.FromSeconds(300)); // 300 = 5 mins