An unofficial .NET API wrapper for Deepgram's automated speech recognition APIs.
DeepgramSharp is a C# client for the Deepgram API. It provides interfaces for both the Livestream and Pre-recorded APIs. If you're struggling to use our library, you're more than welcome to open up an issue or join our Discord server and ask for help in the #deepgram-sharp channel.
DeepgramSharp is available on NuGet. You can install it using the following command:
dotnet add package DeepgramSharp
In order to use the Deepgram API, you must first create a DeepgramClient. The DeepgramClient is the main entry point for the API. It provides methods for creating connections to the Livestream API and sending audio to the Pre-recorded API.
var client = new DeepgramClient("my-api-key");
The livestream API can be used for real-time transcription. It's useful for applications such as live captioning. The livestream API is a WebSocket API. The DeepgramSharp library provides a wrapper around the WebSocket API to make it easier to use.
var livestreamApi = await client.CreateLivestreamAsync(new DeepgramLivestreamOptionCollection()
{
Tier = Nova2Tier.FullName,
Language = CultureInfo.GetCultureInfoByIetfLanguageTag("en-US"),
Punctuate = true
});
DeepgramLivestreamResponse? response;
while((response = await livestreamApi.ReceiveTranscriptionAsync()) != null)
{
switch (response.Type)
{
case DeepgramLivestreamResponseType.Transcription:
Console.WriteLine($"Transcription: {response.Transcription.Text}")
break;
case DeepgramLivestreamResponseType.Error:
Console.WriteLine($"Error: {response.Error.Message}")
break;
case DeepgramLivestreamResponseType.Close:
Console.WriteLine($"Connection closed: {response.Close.Reason}")
break;
}
}
Refer to the Using the Livestream API tutorial for detailed usage instructions.
The pre-recorded API can be used for transcribing audio files. It's useful for applications such as voicemail transcription. The pre-recorded API is a REST API. The DeepgramSharp library provides a wrapper around the REST API to make it easier to use.
var transcription = await client.SendAudioAsync(audioData, new DeepgramAudioOptionCollection()
{
Tier = Nova2Tier.FullName,
Language = CultureInfo.GetCultureInfoByIetfLanguageTag("en-US"),
Punctuate = true
});
Refer to the Using the Pre-recorded API tutorial for detailed usage instructions.
Examples can be found in the examples directory. They demonstrate usage of both the Livestream and Pre-recorded APIs.
The API documentation can be found here. At the time of writing, entities are not documented due to the lack of documentation found on Deepgram's website. Contributions are welcome.
Contributions are welcome. If any warnings are found, try to resolve them before opening the PR. The only exception to this rule is warnings about missing documentation within the Deepgram entities - these can be ignored. If you're unsure about anything, feel free to join the Discord and ask questions in the #deepgram-sharp channel.
This project is licensed under the MIT License - see the LICENSE file for details.