Skip to content

About

Microsoft.Extensions.AI adapter for the official AWS Transcribe .NET SDKs

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

17 Commits

Folders and files

Repository files navigation

AwsTranscribe

Microsoft.Extensions.AI speech-to-text adapter built on the official AWS Transcribe Streaming and batch .NET SDKs.

Nuget package dotnet License: MIT Discord

Official AWS clients

Uses AWSSDK.TranscribeStreaming and AWSSDK.TranscribeService with the standard AWS credential chain and regional endpoints.

True bidirectional streaming

Implements both Microsoft.Extensions.AI STT methods over the AWS HTTP/2 event-stream API without temporary S3 uploads.

Provider details preserved

Alternatives, item timings, confidence, speaker, stability, language, channel, and raw AWS results remain accessible.

Batch API included

Use the exposed official service client for S3-backed batch, medical, call analytics, vocabulary, and language-model operations.

Installation

dotnet add package AwsTranscribe --prerelease

Usage

using AwsTranscribe;
using Microsoft.Extensions.AI;

// Uses the standard AWS SDK credential chain.
using var client = new AwsTranscribeClient(
    regionSystemName: Environment.GetEnvironmentVariable("AWS_REGION")!);

await using var audio = File.OpenRead("sample.pcm");
var response = await client.GetTextAsync(audio, new SpeechToTextOptions
{
    SpeechLanguage = "en-US",
    AdditionalProperties = new()
    {
        [AwsTranscribePropertyNames.MediaEncoding] = "pcm",
        [AwsTranscribePropertyNames.SampleRateHertz] = 16_000,
    },
});

Console.WriteLine(response.Text);

Streaming accepts the encodings supported by AWS Transcribe Streaming: raw little-endian signed 16-bit PCM, FLAC, or Ogg Opus. The media encoding and sample rate must describe the bytes in the supplied stream; a WAV container is not stripped automatically.

For S3-backed jobs, call client.BatchClient.StartTranscriptionJobAsync(...). Advanced streaming options can be applied without losing the MEAI abstraction:

options.AdditionalProperties[AwsTranscribePropertyNames.ConfigureRequest] =
    (Amazon.TranscribeStreaming.Model.StartStreamTranscriptionRequest request) =>
    {
        request.ShowSpeakerLabel = true;
        request.VocabularyName = "product-terms";
    };

Generate

Transcribe a raw PCM, FLAC, or Ogg Opus file with AWS Transcribe Streaming and Microsoft.Extensions.AI.

using var client = new AwsTranscribeClient(regionSystemName);
var samplePath =
    Environment.GetEnvironmentVariable("AWS_TRANSCRIBE_SAMPLE_AUDIO") is { Length: > 0 } samplePathValue
        ? samplePathValue
        : throw new AssertInconclusiveException(
            "AWS_TRANSCRIBE_SAMPLE_AUDIO environment variable is not found.");
var language = Environment.GetEnvironmentVariable("AWS_TRANSCRIBE_LANGUAGE") is { Length: > 0 } languageValue
    ? languageValue
    : AwsTranscribeClient.DefaultLanguage;
var encoding = Environment.GetEnvironmentVariable("AWS_TRANSCRIBE_MEDIA_ENCODING") is { Length: > 0 } encodingValue
    ? encodingValue
    : "pcm";
var sampleRate = Environment.GetEnvironmentVariable("AWS_TRANSCRIBE_SAMPLE_RATE_HERTZ") is { Length: > 0 } rateValue &&
    int.TryParse(rateValue, out var parsedRate)
        ? parsedRate
        : AwsTranscribeClient.DefaultSampleRateHertz;

await using var audio = File.OpenRead(samplePath);
var response = await client.GetTextAsync(audio, new SpeechToTextOptions
{
    SpeechLanguage = language,
    AdditionalProperties = new()
    {
        [AwsTranscribePropertyNames.MediaEncoding] = encoding,
        [AwsTranscribePropertyNames.SampleRateHertz] = sampleRate,
    },
});

Support

Bugs

Open an issue in tryAGI/AwsTranscribe.

Ideas and questions

Use GitHub Discussions for design questions and usage help.

Community

Join the tryAGI Discord for broader discussion across SDKs.

Acknowledgments

This adapter depends on the official AWS SDK for .NET packages and Amazon Transcribe is subject to AWS service terms and pricing.

JetBrains logo

This project is supported by JetBrains through the Open Source Support Program.

About

Microsoft.Extensions.AI adapter for the official AWS Transcribe .NET SDKs

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages