ListLexicon - Amazon Polly
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

ListLexicon

以下 Python 代码示例使用Amazon SDK for Python (Boto) 在本地 Amazon 配置中指定的区域中列出您的账户中的词典。有关创建配置文件的信息,请参阅 步骤 2.1:设置 Amazon 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 Amazon 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))