ListLexicon - Amazon Polly

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

ListLexicon

次の Python コード例では、AWS SDK for Python (Boto) を使用して、ローカルの AWS 設定で指定したリージョンのアカウントのレキシコンをリスト表示します。設定ファイルを作成する方法については、「ステップ 2.1: AWS CLI をセットアップする」を参照してください。

このオペレーションの詳細については、ListLexicons API リファレンスを参照してください。

import sys from boto3 import Session from botocore.exceptions import BotoCoreError, ClientError # Create a client using the credentials and region defined in the adminuser # section of the AWS credentials and configuration files session = Session(profile_name="adminuser") polly = session.client("polly") try: # Request the list of available lexicons response = polly.list_lexicons() except (BotoCoreError, ClientError) as error: # The service returned an error, exit gracefully print(error) sys.exit(-1) # Get the list of lexicons in the response lexicons = response.get("Lexicons", []) print("{0} lexicon(s) found".format(len(lexicons))) # Output a formatted list of lexicons with some of the attributes for lexicon in lexicons: print((u" - {Name} ({Attributes[LanguageCode]}), " "{Attributes[LexemesCount]} lexeme(s)").format(**lexicon))