Microsoft.Extensions.AI speech-to-text adapter built on the official AWS Transcribe Streaming and batch .NET SDKs.
Uses AWSSDK.TranscribeStreaming and AWSSDK.TranscribeService with the standard AWS credential chain and regional endpoints.
Implements both Microsoft.Extensions.AI STT methods over the AWS HTTP/2 event-stream API without temporary S3 uploads.
Alternatives, item timings, confidence, speaker, stability, language, channel, and raw AWS results remain accessible.
dotnet add package AwsTranscribe --prereleaseusing 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";
};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,
},
});Open an issue in tryAGI/AwsTranscribe.
Use GitHub Discussions for design questions and usage help.
Join the tryAGI Discord for broader discussion across SDKs.
This adapter depends on the official AWS SDK for .NET packages and Amazon Transcribe is subject to AWS service terms and pricing.
This project is supported by JetBrains through the Open Source Support Program.
