Skip to content

Commit

Permalink
Merge pull request #129 from jkroll-deepgram/update-samples-and-readmes
Browse files Browse the repository at this point in the history
docs: Fix sample code, add docs for sample app and testing
  • Loading branch information
SandraRodgers authored Sep 6, 2023
2 parents 0982c14 + 06687ce commit 460a300
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
46 changes: 33 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ Official .NET SDK for [Deepgram](https://www.deepgram.com/). Power your apps wit
* [GetUsageSummaryOptions](#getusagesummaryoptions)
* [Get Fields](#get-fields)
* [GetUsageFieldsOptions](#getusagefieldsoptions)
* [Logging](#logging)
* [Development and Contributing](#development-and-contributing)
* [Getting Help](#getting-help)
* [Logging](#logging)
* [Development and Contributing](#development-and-contributing)
* [Testing](#testing)
* [Getting Help](#getting-help)

# Getting an API Key

Expand Down Expand Up @@ -83,8 +84,6 @@ Right click on project and select manage nuget packages

- 7.0.x
- 6.0.x
- 5.0.x
- .NET Core 3.1

# Configuration

Expand All @@ -102,13 +101,15 @@ var deepgramClient = new DeepgramClient(credentials);
## Remote Files

```csharp
using Deepgram.Models;

var credentials = new Credentials(DEEPGRAM_API_KEY);

var deepgramClient = new DeepgramClient(credentials);

var response = await deepgramClient.Transcription.Prerecorded.GetTranscriptionAsync(
new Deepgram.Transcription.UrlSource("https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"),
new Deepgram.Transcription.PrerecordedTranscriptionOptions()
new UrlSource("https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav"),
new PrerecordedTranscriptionOptions()
{
Punctuate = true
});
Expand All @@ -123,17 +124,19 @@ var response = await deepgramClient.Transcription.Prerecorded.GetTranscriptionAs
## Local files

```csharp
using Deepgram.Models;

var credentials = new Credentials(DEEPGRAM_API_KEY);

var deepgramClient = new DeepgramClient(credentials);

using (FileStream fs = File.OpenRead("path\\to\\file"))
{
var response = await deepgramClient.Transcription.Prerecorded.GetTranscriptionAsync(
new Deepgram.Transcription.StreamSource(
new StreamSource(
fs,
"audio/wav"),
new Deepgram.Transcription.PrerecordedTranscriptionOptions()
new PrerecordedTranscriptionOptions()
{
Punctuate = true
});
Expand Down Expand Up @@ -204,6 +207,10 @@ var SRT = preRecordedTranscription.ToSRT();
> pre-recorded transcription.
```csharp
using Deepgram.CustomEventArgs;
using Deepgram.Models;
using System.Net.WebSockets;

var credentials = new Credentials(DEEPGRAM_API_KEY);

var deepgramClient = new DeepgramClient(credentials);
Expand Down Expand Up @@ -304,7 +311,7 @@ using (var deepgramLive = deepgramClient.CreateLiveTranscriptionClient())

# Projects

> projectId and memberId are of type`string`
> projectId and memberId are of type `string`
## Get Projects

Expand Down Expand Up @@ -575,7 +582,7 @@ var result = await deepgramClient.Usage.GetUsageFieldsAsync(projectId,getUsageFi

[See our API reference for more info](https://developers.deepgram.com/reference/get-fields).

## Logging
# Logging

The Library uses Microsoft.Extensions.Logging to preform all of its logging tasks. To configure
logging for your app simply create a new `ILoggerFactory` and call the `LogProvider.SetLogFactory()`
Expand All @@ -596,15 +603,28 @@ factory.AddSerilog(log);
LogProvider.SetLogFactory(factory);
```

## Development and Contributing
# Development and Contributing

Interested in contributing? We ❤️ pull requests!

To make sure our community is safe for all, be sure to review and agree to our
[Code of Conduct](./.github/CODE_OF_CONDUCT.md). Then see the
[Contribution](./.github/CONTRIBUTING.md) guidelines for more information.

## Getting Help
# Testing

The test suite is located within `Deepgram.Tests/`. Run all tests with the following command from the top-level repository:

```bash
dotnet test
```

Upon completion, a summary is printed:
```bash
Passed! - Failed: 0, Passed: 69, Skipped: 0, Total: 69, Duration: 906 ms - Deepgram.Tests.dll (net7.0)
```

# Getting Help

We love to hear from you so if you have questions, comments or find a bug in the
project, let us know! You can either:
Expand Down
9 changes: 9 additions & 0 deletions SampleApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Sample App for Pre-recorded Transcription

To run the sample app, follow a few simple steps.

1. Provide your API key in `Program.cs`: `var credentials = new Credentials("");`
1. From the `SampleApp/` directory, run the command: `dotnet run SampleApp.csproj`
1. The sample file is transcribed and the JSON response is printed to the terminal.

Use this sample app to learn the basics of making Deepgram API calls via the .NET SDK! Reuse and adapt the code for your own projects.

0 comments on commit 460a300

Please sign in to comment.