Amazon Transcribe Streaming Service Speech to text for .NET SDK

Error processing SSI file


  1. Cole

    • 2017/9/2

    This is how I do it:

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Net;
    using System.Threading.Tasks;
    using Amazon;
    using Amazon.S3;
    using Amazon.S3.Model;
    using Amazon.TranscribeService;
    using Amazon.TranscribeService.Model;
    using Newtonsoft.Json;
    using QuickScreenHelper;
    namespace CognitiveFace.Speech
        public class AwsSpeech : IDisposable
            public AwsSpeech(RegionEndpoint regionEndpoint = null)
                RegionEndpoint = regionEndpoint ?? RegionEndpoint.APNortheast1;
                //todo add region endpoint for AWS Face
                S3Client = new AmazonS3Client(RegionEndpoint);
                TranscribeClient = new AmazonTranscribeServiceClient(RegionEndpoint);
            private RegionEndpoint RegionEndpoint { get; }
            private AmazonTranscribeServiceClient TranscribeClient { get; }
            private AmazonS3Client S3Client { get; }
            public void Dispose()
                //TODO remember to call
                //TODO dispose for faceClient
                //todo dispose for gcp speech and azure speech
            public async Task TranscribeInputFile(string fileName, string targetLanguageCode = "ja-JP")
                var bucketName = "transcribe-" + Guid.NewGuid();
                var putBucketResponse = await CreateBucket(bucketName);
                if (putBucketResponse.HttpStatusCode == HttpStatusCode.OK)
                    var uploadInputFileToS3 = await UploadInputFileToS3(fileName, bucketName);
                    if (uploadInputFileToS3.HttpStatusCode == HttpStatusCode.OK)
                        var startTranscriptionJobResponse =
                            await TranscribeInputFile(fileName, bucketName, targetLanguageCode);
                        //todo delete bucket
                        Logger.WriteLine($"Fail to transcribe {fileName} because cannot upload {fileName} to {bucketName}",
                    Logger.WriteLine($"Fail to transcribe {fileName} because cannot create bucket {bucketName}",
            private async Task<TranscriptionJobResult> TranscribeInputFile(string fileName, string bucketName,
                string targetLanguageCode)
                var objectName = Path.GetFileName(fileName);
                var media = new Media()
                    MediaFileUri = $"https://s3.{RegionEndpoint.SystemName}{bucketName}/{objectName}"
                var transcriptionJobName = $"transcribe-job-{bucketName}";
                var transcriptionJobRequest = new StartTranscriptionJobRequest()
                    LanguageCode = targetLanguageCode,
                    Media = media,
                    MediaFormat = MediaFormat.Wav,
                    TranscriptionJobName = transcriptionJobName,
                    OutputBucketName = bucketName
                var startTranscriptionJobResponse =
                    await TranscribeClient.StartTranscriptionJobAsync(transcriptionJobRequest);
                if (startTranscriptionJobResponse.HttpStatusCode == HttpStatusCode.OK)
                    return await WaitForTranscriptionJob(startTranscriptionJobResponse.TranscriptionJob, bucketName);
                    throw new NotImplementedException();
            private async Task<TranscriptionJobResult> WaitForTranscriptionJob(TranscriptionJob transcriptionJob,
                string bucketName, int delayTime = 16000)
                var transcriptionJobTranscriptionJobStatus = transcriptionJob.TranscriptionJobStatus;
                if (transcriptionJobTranscriptionJobStatus ==
                    var keyName = $"{transcriptionJob.TranscriptionJobName}.json";
                    Logger.WriteLine($"Downloading {keyName}");
                    var result = await GetFileFromS3(keyName, bucketName);
                    return JsonConvert.DeserializeObject<TranscriptionJobResult>(result);
                    /*using var stringReader = new StringReader(result);
                    using var jsonTextReader = new JsonTextReader(stringReader);*/
                else if (transcriptionJobTranscriptionJobStatus == TranscriptionJobStatus.FAILED)
                    throw new NotImplementedException();
                    await Task.Delay(delayTime);
                    var getTranscriptionJobResponse = await TranscribeClient.GetTranscriptionJobAsync(
                        new GetTranscriptionJobRequest()
                            TranscriptionJobName = transcriptionJob.TranscriptionJobName
                    return await WaitForTranscriptionJob(getTranscriptionJobResponse.TranscriptionJob, bucketName,
                        delayTime * 2);
            public async Task<PutBucketResponse> CreateBucket(string bucketName)
                var putBucketRequest = new PutBucketRequest()
                    BucketName = bucketName,
                return await S3Client.PutBucketAsync(putBucketRequest);
            public async Task<PutObjectResponse> UploadInputFileToS3(string fileName, string bucketName)
                var objectName = Path.GetFileName(fileName);
                var putObjectRequest = new PutObjectRequest
                    BucketName = bucketName,
                    Key = objectName,
                    ContentType = "audio/wav",
                    FilePath = fileName
                return await S3Client.PutObjectAsync(putObjectRequest);
            public async Task<string> GetFileFromS3(string keyName, string bucketName)
                var request = new GetObjectRequest()
                    BucketName = bucketName,
                    Key = keyName
                using var response = await S3Client.GetObjectAsync(request);
                using var responseStream = response.ResponseStream;
                using var reader = new StreamReader(responseStream);
                /*string title = response.Metadata["x-amz-meta-title"]; // Assume you have "title" as medata added to the object.
                string contentType = response.Headers["Content-Type"];
                Console.WriteLine("Object metadata, Title: {0}", title);
                Console.WriteLine("Content type: {0}", contentType);*/
                return await reader.ReadToEndAsync(); // Now you process the response body.
        //todo move
        public class TranscriptionJobResult
            public string jobName { get; set; }
            public string accountId { get; set; }
            public string status { get; set; }
            public TranscriptionResult results { get; set; }
        public class TranscriptionResult
            public List<Transcript> transcripts { get; set; }
            public List<TranscriptItem> items { get; set; }
        public class Transcript
            public string transcript { get; set; }
        public class TranscriptItem
            public string start_time { get; set; }
            public string end_time { get; set; }
            public List<AlternativeTranscription> alternatives { get; set; }
            public string type { get; set; }
        public class AlternativeTranscription
            public string confidence { get; set; }
            public string content { get; set; }
  2. Thomas

    • 2019/12/16

    I am not able to find any references for transcribe streaming service (from speech to text ) in AWS .NET SDK . Is it available in .NET SDK 

  3. Marcel

    • 2015/1/16

    Search For Transcribe Voice To Text Fast and Save Time. Search For Transcribe Voice To Text Here.

  4. Morel

    • 2016/3/31

    Amazon Transcribe is an automatic speech recognition (ASR) service that makes it easy for developers to add speech to text capability to their applications.

  5. Rocco

    • 2018/9/5

    Probably not, for the .NET i found nothing. I was searching for the JavaScritpt SDK too and i found an GitHub issue where it was replied that it is not yet supported.

    Based on this official blog post, the real time transcription feature are very recent, this may explain the lack of SDKs (20 NOV 2018)

    I only found a example using the Java SDK: Example Java Application using AWS SDK creating streaming transcriptions via AWS Transcribe

    UPDATE: I got in touch and they gave me this answer:

    Right now only the Java and Ruby SDKs support streaming transcription. If you want to use the .NET Framework or JavaScript you’ll need to write your own client. If you decide to do that, you might find the documentation on this page useful:

  6. Alvarez

    • 2021/7/3

    Find Transcribe voice to text. Search For Transcribe voice to text With Us.

  7. Conte

    • 2016/11/28

    I am not able to find any references for transcribe streaming service (from speech to text ) in AWS .NET SDK . Is it available in .NET SDK Amazon Transcribe 

  8. Axel

    • 2017/9/16

    Looking for transcript voice to text? Search now! Content updated daily for transcript voice to text

  9. Magnus

    • 2016/11/20

    Amazon Transcribe can be used to transcribe customer service calls, You can use Amazon Transcribe Medical to add medical speech to text 

  10. Taylor

    • 2016/11/13 updates its results daily to help you find what you are looking for. Find transcribe sound to text on

  11. Eddie

    • 2018/8/25

    Using the Amazon Transcribe API, you can analyze audio files stored in Amazon S3 and have the service return a text file of the transcribed speech.

  12. Warren

    • 2019/8/21

    This is the newest place to search, delivering top results from across the web. Find content updated daily for dictate voice to text.

  13. Tucker

    • 2015/11/24

    Using Automatic Speech Recognition (ASR) technology, customers can choose to use Amazon Transcribe API will be able to detect the quality of the audio 

  14. Gregory

    • 2020/11/20

    I am not able to find any references for transcribe streaming service (from speech to text ) in AWS .NET SDK . Is it available in .NET SDK Amazon Transcribe Streaming Service ? Any references would be helpful

  15. Aries

    • 2015/2/11

    Create a new .NET Core console application project. Comprehend. Add the following Nuget packages to the project: AWSSDK.TranscribeService; AWSSDK.

  16. Rory

    • 2016/9/25

    Amazon Transcribe makes it easy for developers to add speech to text capabilities to their applications. Audio data is virtually impossible for computers to search and analyze. Therefore, recorded speech needs to be converted to text before it can be used in applications. Historically, customers had to work with transcription providers that required them to sign expensive contracts and were hard to integrate into their technology stacks to accomplish this task.

  17. Adrien

    • 2020/10/24

    Kindle. RSS. Use Amazon Transcribe streaming transcription to send an audio stream and receive a stream of text in real time. You can use this text stream to add real-time speech-to-text capability to your applications. Streaming transcription takes a stream of your audio data and transcribes it in real time.

  18. Noel

    • 2018/7/18

    You can specify an AWS Key Management Service (KMS) key to encrypt the output of your transcription using the OutputEncryptionKMSKeyId parameter. If you don't specify a KMS key, Amazon Transcribe uses the default Amazon S3 key for server-side encryption of transcripts that are placed in your S3 bucket.

  19. Martinez

    • 2019/12/13

    AWS #Transcribe Speech to Text using C#. March 4, 2021 Infinite Loop Development Ltd Leave a comment. AWS has a transcribe service which converts audio containing speech to text. It is very tightly integrated with the AWS ecosystem, so it’s probably best used for systems that are already using AWS for other services – specifically, S3 for storage of audio, and perhaps Cloudwatch and Lambda for post processing.

Comments are closed.

More Posts