Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Swimburger committed Aug 22, 2024
2 parents 5beeaee + 40127ec commit c9c8ead
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Samples/MicrophoneStream/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Microsoft.Extensions.Configuration;

var transcriptWords = new SortedDictionary<int, string>();

string BuildTranscript()
{
var stringBuilder = new StringBuilder();
Expand Down Expand Up @@ -34,7 +35,8 @@ string BuildTranscript()
});

transcriber.PartialTranscriptReceived.Subscribe(transcript =>
{ // don't do anything if nothing was said
{
// don't do anything if nothing was said
if (string.IsNullOrEmpty(transcript.Text)) return;
transcriptWords[transcript.AudioStart] = transcript.Text;
Expand Down Expand Up @@ -101,4 +103,4 @@ string BuildTranscript()
}

soxProcess.Kill();
await transcriber.CloseAsync();
await transcriber.CloseAsync();
18 changes: 18 additions & 0 deletions Samples/MicrophoneStream/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Transcribe audio from the microphone in real-time

The following things are required to run the sample:
* [.NET 8 or up](https://dotnet.microsoft.com/en-us/download)
* [Install SoX and add it to the PATH environment variable](https://sourceforge.net/projects/sox/)
* An [AssemblyAI](https://www.assemblyai.com/dashboard/signup) account with credit card set up
* Configure [your AssemblyAI API key](https://www.assemblyai.com/app/account) using .NET user-secrets:
```bash
dotnet user-secrets set AssemblyAI:ApiKey [YOUR_API_KEY]
```

Now run the sample:

```bash
dotnet run
```

Speak into your microphone to see your speech transcribed in real-time.
8 changes: 8 additions & 0 deletions Samples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Samples for the AssemblyAI C# .NET SDK

This solution contains a variety of samples that show how to use the AssemblyAI SDK for C# .NET.

* [MicrophoneStream](./MicrophoneStream): A console app to transcribe speech from the microphone in real-time.
* [Avalonia](./Avalonia): An Avalonia app that lets you transcribe audio files, prompt LLMs using LeMUR, and transcribe speech from the microphone in real-time.
* [BlazorSample](./BlazorSample): A Blazor WASM and Server app that lets you transcribe audio files, prompt LLMs using LeMUR, and transcribe speech from the microphone in real-time.
* [TwilioVoice](./TwilioVoice): An ASP.NET Core app that uses Twilio Media Streams to transcribe speech from Twilio Voice calls in real-time.

0 comments on commit c9c8ead

Please sign in to comment.