ListLexicon - Amazon Polly

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

ListLexicon

Contoh kode Python berikut menggunakan daftar leksikon di akun Anda di wilayah yang ditentukan dalam konfigurasi lokal Anda. AWS SDK for Python (Boto) AWS Untuk informasi tentang membuat file konfigurasi, lihatLangkah 2.1: Mengatur AWS CLI.

Untuk informasi selengkapnya tentang operasi ini, lihat referensi untuk ListLexiconsAPI.

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))