ListLexicon - Amazon Polly

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

ListLexicon

AWS SDK for Python (Boto) 以下 Python 代码示例使用列出您账户中位于本地 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))