startSpeechSynthesisTask method
- required OutputFormat outputFormat,
- required String outputS3BucketName,
- required String text,
- required VoiceId voiceId,
- Engine? engine,
- LanguageCode? languageCode,
- List<
String> ? lexiconNames, - String? outputS3KeyPrefix,
- String? sampleRate,
- String? snsTopicArn,
- List<
SpeechMarkType> ? speechMarkTypes, - TextType? textType,
Allows the creation of an asynchronous synthesis task, by starting a new
SpeechSynthesisTask. This operation requires all the standard
information needed for speech synthesis, plus the name of an Amazon S3
bucket for the service to store the output of the synthesis task and two
optional parameters (OutputS3KeyPrefix and
SnsTopicArn). Once the synthesis task is created, this
operation will return a SpeechSynthesisTask object, which
will include an identifier of this task as well as the current status. The
SpeechSynthesisTask object is available for 72 hours after
starting the asynchronous synthesis task.
May throw EngineNotSupportedException.
May throw InvalidS3BucketException.
May throw InvalidS3KeyException.
May throw InvalidSampleRateException.
May throw InvalidSnsTopicArnException.
May throw InvalidSsmlException.
May throw LanguageNotSupportedException.
May throw LexiconNotFoundException.
May throw MarksNotSupportedForFormatException.
May throw ServiceFailureException.
May throw SsmlMarksNotSupportedForTextTypeException.
May throw TextLengthExceededException.
Parameter outputFormat :
The format in which the returned output will be encoded. For audio stream,
this will be mp3, ogg_vorbis, ogg_opus, mu-law, a-law, or pcm. For speech
marks, this will be json.
Parameter outputS3BucketName :
Amazon S3 bucket name to which the output file will be saved.
Parameter text :
The input text to synthesize. If you specify ssml as the TextType, follow
the SSML format for the input text.
Parameter voiceId :
Voice ID to use for the synthesis.
Parameter engine :
Specifies the engine (standard, neural,
long-form or generative) for Amazon Polly to use
when processing input text for speech synthesis. Using a voice that is not
supported for the engine selected will result in an error.
Parameter languageCode :
Optional language code for the Speech Synthesis request. This is only
necessary if using a bilingual voice, such as Aditi, which can be used for
either Indian English (en-IN) or Hindi (hi-IN).
If a bilingual voice is used and no language code is specified, Amazon
Polly uses the default language of the bilingual voice. The default
language for any voice is the one returned by the DescribeVoices
operation for the LanguageCode parameter. For example, if no
language code is specified, Aditi will use Indian English rather than
Hindi.
Parameter lexiconNames :
List of one or more pronunciation lexicon names you want the service to
apply during synthesis. Lexicons are applied only if the language of the
lexicon is the same as the language of the voice.
Parameter outputS3KeyPrefix :
The Amazon S3 key prefix for the output speech file.
Parameter sampleRate :
The audio frequency specified in Hz.
The valid values for mp3 and ogg_vorbis are "8000", "16000", "22050", and "24000". The default value for standard voices is "22050". The default value for neural voices is "24000". The default value for long-form voices is "24000". The default value for generative voices is "24000".
Valid values for pcm are "8000" and "16000" The default value is "16000".
Valid value for ogg_opus is "48000".
Valid value for mu-law and a-law is "8000".
Parameter snsTopicArn :
ARN for the SNS topic optionally used for providing status notification
for a speech synthesis task.
Parameter speechMarkTypes :
The type of speech marks returned for the input text.
Parameter textType :
Specifies whether the input text is plain text or SSML. The default value
is plain text.
Implementation
Future<StartSpeechSynthesisTaskOutput> startSpeechSynthesisTask({
required OutputFormat outputFormat,
required String outputS3BucketName,
required String text,
required VoiceId voiceId,
Engine? engine,
LanguageCode? languageCode,
List<String>? lexiconNames,
String? outputS3KeyPrefix,
String? sampleRate,
String? snsTopicArn,
List<SpeechMarkType>? speechMarkTypes,
TextType? textType,
}) async {
final $payload = <String, dynamic>{
'OutputFormat': outputFormat.value,
'OutputS3BucketName': outputS3BucketName,
'Text': text,
'VoiceId': voiceId.value,
if (engine != null) 'Engine': engine.value,
if (languageCode != null) 'LanguageCode': languageCode.value,
if (lexiconNames != null) 'LexiconNames': lexiconNames,
if (outputS3KeyPrefix != null) 'OutputS3KeyPrefix': outputS3KeyPrefix,
if (sampleRate != null) 'SampleRate': sampleRate,
if (snsTopicArn != null) 'SnsTopicArn': snsTopicArn,
if (speechMarkTypes != null)
'SpeechMarkTypes': speechMarkTypes.map((e) => e.value).toList(),
if (textType != null) 'TextType': textType.value,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri: '/v1/synthesisTasks',
exceptionFnMap: _exceptionFns,
);
return StartSpeechSynthesisTaskOutput.fromJson(response);
}