// // Copyright 2010-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"). // You may not use this file except in compliance with the License. // A copy of the License is located at // // http://aws.amazon.com/apache2.0 // // or in the "license" file accompanying this file. This file is distributed // on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either // express or implied. See the License for the specific language governing // permissions and limitations under the License. // #import "AWSTranscribeStreamingResources.h" #import @interface AWSTranscribeStreamingResources () @property (nonatomic, strong) NSDictionary *definitionDictionary; @end @implementation AWSTranscribeStreamingResources + (instancetype)sharedInstance { static AWSTranscribeStreamingResources *_sharedResources = nil; static dispatch_once_t once_token; dispatch_once(&once_token, ^{ _sharedResources = [AWSTranscribeStreamingResources new]; }); return _sharedResources; } - (NSDictionary *)JSONObject { return self.definitionDictionary; } - (instancetype)init { if (self = [super init]) { //init method NSError *error = nil; _definitionDictionary = [NSJSONSerialization JSONObjectWithData:[[self definitionString] dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error]; if (_definitionDictionary == nil) { if (error) { AWSDDLogError(@"Failed to parse JSON service definition: %@",error); } } } return self; } - (nonnull NSString *)definitionString { return @"{\ \"version\":\"2.0\",\ \"metadata\":{\ \"apiVersion\":\"2017-10-26\",\ \"endpointPrefix\":\"transcribestreaming\",\ \"protocol\":\"rest-json\",\ \"protocolSettings\":{\"h2\":\"eventstream\"},\ \"serviceFullName\":\"Amazon Transcribe Streaming Service\",\ \"serviceId\":\"Transcribe Streaming\",\ \"signatureVersion\":\"v4\",\ \"signingName\":\"transcribe\",\ \"uid\":\"transcribe-streaming-2017-10-26\"\ },\ \"operations\":{\ \"StartStreamTranscription\":{\ \"name\":\"StartStreamTranscription\",\ \"http\":{\ \"method\":\"POST\",\ \"requestUri\":\"/stream-transcription\"\ },\ \"input\":{\"shape\":\"StartStreamTranscriptionRequest\"},\ \"output\":{\"shape\":\"StartStreamTranscriptionResponse\"},\ \"errors\":[\ {\"shape\":\"BadRequestException\"},\ {\"shape\":\"LimitExceededException\"},\ {\"shape\":\"InternalFailureException\"},\ {\"shape\":\"ConflictException\"},\ {\"shape\":\"ServiceUnavailableException\"}\ ],\ \"documentation\":\"

Starts a bidirectional HTTP2 stream where audio is streamed to Amazon Transcribe and the transcription results are streamed to your application.

The following are encoded as HTTP2 headers:

\"\ }\ },\ \"shapes\":{\ \"Alternative\":{\ \"type\":\"structure\",\ \"members\":{\ \"Transcript\":{\ \"shape\":\"String\",\ \"documentation\":\"

The text that was transcribed from the audio.

\"\ },\ \"Items\":{\ \"shape\":\"ItemList\",\ \"documentation\":\"

One or more alternative interpretations of the input audio.

\"\ }\ },\ \"documentation\":\"

A list of possible transcriptions for the audio.

\"\ },\ \"AlternativeList\":{\ \"type\":\"list\",\ \"member\":{\"shape\":\"Alternative\"}\ },\ \"AudioChunk\":{\"type\":\"blob\"},\ \"AudioEvent\":{\ \"type\":\"structure\",\ \"members\":{\ \"AudioChunk\":{\ \"shape\":\"AudioChunk\",\ \"documentation\":\"

An audio blob that contains the next part of the audio that you want to transcribe.

\",\ \"eventpayload\":true\ }\ },\ \"documentation\":\"

Provides a wrapper for the audio chunks that you are sending.

\",\ \"event\":true\ },\ \"AudioStream\":{\ \"type\":\"structure\",\ \"members\":{\ \"AudioEvent\":{\ \"shape\":\"AudioEvent\",\ \"documentation\":\"

A blob of audio from your application. You audio stream consists of one or more audio events.

\"\ }\ },\ \"documentation\":\"

Represents the audio stream from your application to Amazon Transcribe.

\",\ \"eventstream\":true\ },\ \"BadRequestException\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"String\"}\ },\ \"documentation\":\"

One or more arguments to the StartStreamTranscription operation was invalid. For example, MediaEncoding was not set to pcm or LanguageCode was not set to a valid code. Check the parameters and try your request again.

\",\ \"error\":{\"httpStatusCode\":400},\ \"exception\":true\ },\ \"Boolean\":{\"type\":\"boolean\"},\ \"ConflictException\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"String\"}\ },\ \"documentation\":\"

A new stream started with the same session ID. The current stream has been terminated.

\",\ \"error\":{\"httpStatusCode\":409},\ \"exception\":true\ },\ \"Double\":{\"type\":\"double\"},\ \"InternalFailureException\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"String\"}\ },\ \"documentation\":\"

A problem occurred while processing the audio. Amazon Transcribe terminated processing. Try your request again.

\",\ \"error\":{\"httpStatusCode\":500},\ \"exception\":true,\ \"fault\":true\ },\ \"Item\":{\ \"type\":\"structure\",\ \"members\":{\ \"StartTime\":{\ \"shape\":\"Double\",\ \"documentation\":\"

The offset from the beginning of the audio stream to the beginning of the audio that resulted in the item.

\"\ },\ \"EndTime\":{\ \"shape\":\"Double\",\ \"documentation\":\"

The offset from the beginning of the audio stream to the end of the audio that resulted in the item.

\"\ },\ \"Type\":{\ \"shape\":\"ItemType\",\ \"documentation\":\"

The type of the item. PRONUNCIATION indicates that the item is a word that was recognized in the input audio. PUNCTUATION indicates that the item was interpreted as a pause in the input audio.

\"\ },\ \"Content\":{\ \"shape\":\"String\",\ \"documentation\":\"

The word or punctuation that was recognized in the input audio.

\"\ }\ },\ \"documentation\":\"

A word or phrase transcribed from the input audio.

\"\ },\ \"ItemList\":{\ \"type\":\"list\",\ \"member\":{\"shape\":\"Item\"}\ },\ \"ItemType\":{\ \"type\":\"string\",\ \"enum\":[\ \"PRONUNCIATION\",\ \"PUNCTUATION\"\ ]\ },\ \"LanguageCode\":{\ \"type\":\"string\",\ \"enum\":[\ \"en-US\",\ \"en-GB\",\ \"es-US\",\ \"fr-CA\",\ \"fr-FR\",\ \"en-AU\",\ \"it-IT\",\ \"de-DE\",\ \"pt-BR\",\ \"ja-JP\",\ \"ko-KR\",\ \"zh-CN\",\ \"hi-IN\",\ \"th-TH\"\ ]\ },\ \"LimitExceededException\":{\ \"type\":\"structure\",\ \"members\":{\ \"Message\":{\"shape\":\"String\"}\ },\ \"documentation\":\"

You have exceeded the maximum number of concurrent transcription streams, are starting transcription streams too quickly, or the maximum audio length of 4 hours. Wait until a stream has finished processing, or break your audio stream into smaller chunks and try your request again.

\",\ \"error\":{\"httpStatusCode\":429},\ \"exception\":true\ },\ \"MediaEncoding\":{\ \"type\":\"string\",\ \"enum\":[\"pcm\"]\ },\ \"MediaSampleRateHertz\":{\ \"type\":\"integer\",\ \"max\":48000,\ \"min\":8000\ },\ \"RequestId\":{\"type\":\"string\"},\ \"Result\":{\ \"type\":\"structure\",\ \"members\":{\ \"ResultId\":{\ \"shape\":\"String\",\ \"documentation\":\"

A unique identifier for the result.

\"\ },\ \"StartTime\":{\ \"shape\":\"Double\",\ \"documentation\":\"

The offset in milliseconds from the beginning of the audio stream to the beginning of the result.

\"\ },\ \"EndTime\":{\ \"shape\":\"Double\",\ \"documentation\":\"

The offset in milliseconds from the beginning of the audio stream to the end of the result.

\"\ },\ \"IsPartial\":{\ \"shape\":\"Boolean\",\ \"documentation\":\"

true to indicate that Amazon Transcribe has additional transcription data to send, false to indicate that this is the last transcription result for the audio stream.

\"\ },\ \"Alternatives\":{\ \"shape\":\"AlternativeList\",\ \"documentation\":\"

A list of possible transcriptions for the audio. Each alternative typically contains one item that contains the result of the transcription.

\"\ }\ },\ \"documentation\":\"

The result of transcribing a portion of the input audio stream.

\"\ },\ \"ResultList\":{\ \"type\":\"list\",\ \"member\":{\"shape\":\"Result\"}\ },\ \"SessionId\":{\ \"type\":\"string\",\ \"pattern\":\"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\"\ },\ \"StartStreamTranscriptionRequest\":{\ \"type\":\"structure\",\ \"required\":[\ \"LanguageCode\",\ \"MediaSampleRateHertz\",\ \"MediaEncoding\",\ \"AudioStream\"\ ],\ \"members\":{\ \"LanguageCode\":{\ \"shape\":\"LanguageCode\",\ \"documentation\":\"

Indicates the language used in the input audio stream.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-language-code\"\ },\ \"MediaSampleRateHertz\":{\ \"shape\":\"MediaSampleRateHertz\",\ \"documentation\":\"

The sample rate, in Hertz, of the input audio. We suggest that you use 8000 Hz for low quality audio and 16000 Hz for high quality audio.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-sample-rate\"\ },\ \"MediaEncoding\":{\ \"shape\":\"MediaEncoding\",\ \"documentation\":\"

The encoding used for the input audio.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-media-encoding\"\ },\ \"VocabularyName\":{\ \"shape\":\"VocabularyName\",\ \"documentation\":\"

The name of the vocabulary to use when processing the transcription job.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-vocabulary-name\"\ },\ \"SessionId\":{\ \"shape\":\"SessionId\",\ \"documentation\":\"

A identifier for the transcription session. Use this parameter when you want to retry a session. If you don't provide a session ID, Amazon Transcribe will generate one for you and return it in the response.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-session-id\"\ },\ \"AudioStream\":{\ \"shape\":\"AudioStream\",\ \"documentation\":\"

PCM-encoded stream of audio blobs. The audio stream is encoded as an HTTP2 data frame.

\"\ }\ },\ \"payload\":\"AudioStream\"\ },\ \"StartStreamTranscriptionResponse\":{\ \"type\":\"structure\",\ \"members\":{\ \"RequestId\":{\ \"shape\":\"RequestId\",\ \"documentation\":\"

An identifier for the streaming transcription.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-request-id\"\ },\ \"LanguageCode\":{\ \"shape\":\"LanguageCode\",\ \"documentation\":\"

The language code for the input audio stream.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-language-code\"\ },\ \"MediaSampleRateHertz\":{\ \"shape\":\"MediaSampleRateHertz\",\ \"documentation\":\"

The sample rate for the input audio stream. Use 8000 Hz for low quality audio and 16000 Hz for high quality audio.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-sample-rate\"\ },\ \"MediaEncoding\":{\ \"shape\":\"MediaEncoding\",\ \"documentation\":\"

The encoding used for the input audio stream.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-media-encoding\"\ },\ \"VocabularyName\":{\ \"shape\":\"VocabularyName\",\ \"documentation\":\"

The name of the vocabulary used when processing the job.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-vocabulary-name\"\ },\ \"SessionId\":{\ \"shape\":\"SessionId\",\ \"documentation\":\"

An identifier for a specific transcription session.

\",\ \"location\":\"header\",\ \"locationName\":\"x-amzn-transcribe-session-id\"\ },\ \"TranscriptResultStream\":{\ \"shape\":\"TranscriptResultStream\",\ \"documentation\":\"

Represents the stream of transcription events from Amazon Transcribe to your application.

\"\ }\ },\ \"payload\":\"TranscriptResultStream\"\ },\ \"String\":{\"type\":\"string\"},\ \"Transcript\":{\ \"type\":\"structure\",\ \"members\":{\ \"Results\":{\ \"shape\":\"ResultList\",\ \"documentation\":\"

Result objects that contain the results of transcribing a portion of the input audio stream. The array can be empty.

\"\ }\ },\ \"documentation\":\"

The transcription in a TranscriptEvent.

\"\ },\ \"TranscriptEvent\":{\ \"type\":\"structure\",\ \"members\":{\ \"Transcript\":{\ \"shape\":\"Transcript\",\ \"documentation\":\"

The transcription of the audio stream. The transcription is composed of all of the items in the results list.

\"\ }\ },\ \"documentation\":\"

Represents a set of transcription results from the server to the client. It contains one or more segments of the transcription.

\",\ \"event\":true\ },\ \"TranscriptResultStream\":{\ \"type\":\"structure\",\ \"members\":{\ \"TranscriptEvent\":{\ \"shape\":\"TranscriptEvent\",\ \"documentation\":\"

A portion of the transcription of the audio stream. Events are sent periodically from Amazon Transcribe to your application. The event can be a partial transcription of a section of the audio stream, or it can be the entire transcription of that portion of the audio stream.

\"\ },\ \"BadRequestException\":{\ \"shape\":\"BadRequestException\",\ \"documentation\":\"

A client error occurred when the stream was created. Check the parameters of the request and try your request again.

\"\ },\ \"LimitExceededException\":{\ \"shape\":\"LimitExceededException\",\ \"documentation\":\"

Your client has exceeded one of the Amazon Transcribe limits, typically the limit on audio length. Break your audio stream into smaller chunks and try your request again.

\"\ },\ \"InternalFailureException\":{\ \"shape\":\"InternalFailureException\",\ \"documentation\":\"

A problem occurred while processing the audio. Amazon Transcribe terminated processing.

\"\ },\ \"ConflictException\":{\ \"shape\":\"ConflictException\",\ \"documentation\":\"

A new stream started with the same session ID. The current stream has been terminated.

\"\ }\ },\ \"documentation\":\"

Represents the transcription result stream from Amazon Transcribe to your application.

\",\ \"eventstream\":true\ },\ \"VocabularyName\":{\ \"type\":\"string\",\ \"max\":200,\ \"min\":1,\ \"pattern\":\"^[0-9a-zA-Z._-]+\"\ }\ },\ \"documentation\":\"

Operations and objects for transcribing streaming speech to text.

\"\ }"; } @end