createVocabularyFilter method
- required LanguageCode languageCode,
- required String vocabularyFilterName,
- String? vocabularyFilterFileUri,
- List<
String> ? words,
Creates a new vocabulary filter that you can use to filter words, such as profane words, from the output of a transcription job.
May throw BadRequestException. May throw LimitExceededException. May throw InternalFailureException. May throw ConflictException.
Parameter languageCode
:
The language code of the words in the vocabulary filter. All words in the
filter must be in the same language. The vocabulary filter can only be
used with transcription jobs in the specified language.
Parameter vocabularyFilterName
:
The vocabulary filter name. The name must be unique within the account
that contains it. If you try to create a vocabulary filter with the same
name as another vocabulary filter, you get a
ConflictException
error.
Parameter vocabularyFilterFileUri
:
The Amazon S3 location of a text file used as input to create the
vocabulary filter. Only use characters from the character set defined for
custom vocabularies. For a list of character sets, see Character
Sets for Custom Vocabularies.
The specified file must be less than 50 KB of UTF-8 characters.
If you provide the location of a list of words in the
VocabularyFilterFileUri
parameter, you can't use the
Words
parameter.
Parameter words
:
The words to use in the vocabulary filter. Only use characters from the
character set defined for custom vocabularies. For a list of character
sets, see Character
Sets for Custom Vocabularies.
If you provide a list of words in the Words
parameter, you
can't use the VocabularyFilterFileUri
parameter.
Implementation
Future<CreateVocabularyFilterResponse> createVocabularyFilter({
required LanguageCode languageCode,
required String vocabularyFilterName,
String? vocabularyFilterFileUri,
List<String>? words,
}) async {
ArgumentError.checkNotNull(languageCode, 'languageCode');
ArgumentError.checkNotNull(vocabularyFilterName, 'vocabularyFilterName');
_s.validateStringLength(
'vocabularyFilterName',
vocabularyFilterName,
1,
200,
isRequired: true,
);
_s.validateStringLength(
'vocabularyFilterFileUri',
vocabularyFilterFileUri,
1,
2000,
);
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Transcribe.CreateVocabularyFilter'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'LanguageCode': languageCode.toValue(),
'VocabularyFilterName': vocabularyFilterName,
if (vocabularyFilterFileUri != null)
'VocabularyFilterFileUri': vocabularyFilterFileUri,
if (words != null) 'Words': words,
},
);
return CreateVocabularyFilterResponse.fromJson(jsonResponse.body);
}