翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
を使用してカスタム Amazon Transcribe ボキャブラリーを一覧表示するAWSSDK
これらは Amazon Transcribe のカスタムボキャブラリを呼び出すもので、コンテキスト内で実行する必要がある大規模なコード抜粋です。
アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。
- .NET
-
- AWS SDK for .NET
-
/// <summary>
/// List custom vocabularies for the current account. Optionally specify a name
/// filter and a specific state to filter the vocabularies list.
/// </summary>
/// <param name="nameContains">Optional string the vocabulary name must contain.</param>
/// <param name="stateEquals">Optional state of the vocabulary.</param>
/// <returns>List of information about the vocabularies.</returns>
public async Task<List<VocabularyInfo>> ListCustomVocabularies(string? nameContains = null,
VocabularyState? stateEquals = null)
{
var response = await _amazonTranscribeService.ListVocabulariesAsync(
new ListVocabulariesRequest()
{
NameContains = nameContains,
StateEquals = stateEquals
});
return response.Vocabularies;
}
- Python
-
- SDK for Python (Boto3)
-
def list_vocabularies(vocabulary_filter, transcribe_client):
"""
Lists the custom vocabularies created for this AWS account.
:param vocabulary_filter: The returned vocabularies must contain this string in
their names.
:param transcribe_client: The Boto3 Transcribe client.
:return: The list of retrieved vocabularies.
"""
try:
response = transcribe_client.list_vocabularies(
NameContains=vocabulary_filter)
vocabs = response['Vocabularies']
next_token = response.get('NextToken')
while next_token is not None:
response = transcribe_client.list_vocabularies(
NameContains=vocabulary_filter, NextToken=next_token)
vocabs += response['Vocabularies']
next_token = response.get('NextToken')
logger.info(
"Got %s vocabularies with filter %s.", len(vocabs), vocabulary_filter)
except ClientError:
logger.exception(
"Couldn't list vocabularies with filter %s.", vocabulary_filter)
raise
else:
return vocabs
AWS SDK デベロッパーガイドとコード例の詳細なリストについては、「このサービスを AWS SDK で使用する」を参照してください。このトピックには、使用開始方法に関する情報と、以前の SDK バージョンの詳細も含まれています。