UpdateVocabulary で を使用する AWS SDK または CLI - Amazon Transcribe

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

UpdateVocabulary で を使用する AWS SDK または CLI

以下のコード例は、UpdateVocabulary の使用方法を示しています。

アクション例は、より大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。次のコード例で、このアクションのコンテキストを確認できます。

.NET
AWS SDK for .NET
注記

については、「」を参照してください GitHub。完全な例を検索し、 でセットアップして実行する方法を学びます。 AWS コード例リポジトリ

/// <summary> /// Update a custom vocabulary with new values. Update overwrites all existing information. /// </summary> /// <param name="languageCode">The language code of the vocabulary.</param> /// <param name="phrases">Phrases to use in the vocabulary.</param> /// <param name="vocabularyName">Name for the vocabulary.</param> /// <returns>The state of the custom vocabulary.</returns> public async Task<VocabularyState> UpdateCustomVocabulary(LanguageCode languageCode, List<string> phrases, string vocabularyName) { var response = await _amazonTranscribeService.UpdateVocabularyAsync( new UpdateVocabularyRequest() { LanguageCode = languageCode, Phrases = phrases, VocabularyName = vocabularyName }); return response.VocabularyState; }
  • API 詳細については、UpdateVocabulary「」の「」を参照してください 。AWS SDK for .NET API リファレンス

CLI
AWS CLI

カスタム語彙を新しい用語で更新するには

次の update-vocabulary の例は、カスタム語彙の作成に使用した用語を、指定した新しい用語で上書きします。前提条件: カスタム語彙の用語を置き換えるには、新しい用語を含むファイルが必要です。

aws transcribe update-vocabulary \ --vocabulary-file-uri s3://DOC-EXAMPLE-BUCKET/Amazon-S3-Prefix/custom-vocabulary.txt \ --vocabulary-name custom-vocabulary \ --language-code language-code

出力:

{ "VocabularyName": "custom-vocabulary", "LanguageCode": "language", "VocabularyState": "PENDING" }

詳細については、「Amazon Transcribe デベロッパーガイド」の「カスタムボキャブラリー」を参照してください。

  • API 詳細については、UpdateVocabulary「」の「」を参照してください 。AWS CLI コマンドリファレンス

Python
SDK for Python (Boto3)
注記

については、「」を参照してください GitHub。完全な例を検索し、 で をセットアップして実行する方法について説明します。 AWS コード例リポジトリ

def update_vocabulary( vocabulary_name, language_code, transcribe_client, phrases=None, table_uri=None ): """ Updates an existing custom vocabulary. The entire vocabulary is replaced with the contents of the update. :param vocabulary_name: The name of the vocabulary to update. :param language_code: The language code of the vocabulary. :param transcribe_client: The Boto3 Transcribe client. :param phrases: A list of comma-separated phrases to include in the vocabulary. :param table_uri: A table of phrases and pronunciation hints to include in the vocabulary. """ try: vocab_args = {"VocabularyName": vocabulary_name, "LanguageCode": language_code} if phrases is not None: vocab_args["Phrases"] = phrases elif table_uri is not None: vocab_args["VocabularyFileUri"] = table_uri response = transcribe_client.update_vocabulary(**vocab_args) logger.info("Updated custom vocabulary %s.", response["VocabularyName"]) except ClientError: logger.exception("Couldn't update custom vocabulary %s.", vocabulary_name) raise
  • API 詳細については、UpdateVocabulary「」の「」を参照してください 。AWS SDK for Python (Boto3) APIリファレンス

の完全なリストについては AWS SDK デベロッパーガイドとコード例については、「」を参照してくださいAWS SDK でこのサービスを使用する。このトピックには、開始方法に関する情報と以前のSDKバージョンの詳細も含まれています。