createVocabulary method
- required LanguageCode languageCode,
- required String vocabularyName,
- List<
String> ? phrases, - String? vocabularyFileUri,
Creates a new custom vocabulary that you can use to change the way Amazon Transcribe handles transcription of an audio file.
May throw BadRequestException. May throw LimitExceededException. May throw InternalFailureException. May throw ConflictException.
Parameter languageCode
:
The language code of the vocabulary entries.
Parameter vocabularyName
:
The name of the vocabulary. The name must be unique within an AWS account.
The name is case sensitive. If you try to create a vocabulary with the
same name as a previous vocabulary you will receive a
ConflictException
error.
Parameter phrases
:
An array of strings that contains the vocabulary entries.
Parameter vocabularyFileUri
:
The S3 location of the text file that contains the definition of the
custom vocabulary. The URI must be in the same region as the API endpoint
that you are calling. The general form is
For more information about S3 object names, see Object Keys in the Amazon S3 Developer Guide.
For more information about custom vocabularies, see Custom Vocabularies.
Implementation
Future<CreateVocabularyResponse> createVocabulary({
required LanguageCode languageCode,
required String vocabularyName,
List<String>? phrases,
String? vocabularyFileUri,
}) async {
ArgumentError.checkNotNull(languageCode, 'languageCode');
ArgumentError.checkNotNull(vocabularyName, 'vocabularyName');
_s.validateStringLength(
'vocabularyName',
vocabularyName,
1,
200,
isRequired: true,
);
_s.validateStringLength(
'vocabularyFileUri',
vocabularyFileUri,
1,
2000,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Transcribe.CreateVocabulary'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'LanguageCode': languageCode.toValue(),
'VocabularyName': vocabularyName,
if (phrases != null) 'Phrases': phrases,
if (vocabularyFileUri != null) 'VocabularyFileUri': vocabularyFileUri,
},
);
return CreateVocabularyResponse.fromJson(jsonResponse.body);
}