DeleteLexicon - Amazon Polly

DeleteLexicon

다음 Python 코드 예제는 AWS SDK for Python (Boto)를 사용하여 로컬 AWS 구성에 지정한 리전의 어휘를 삭제합니다. 이 예에서는 지정한 어휘만 삭제합니다. 실제로 어휘를 삭제하기 전에 계속 진행할 것인지 묻는 메시지가 표시됩니다.

다음 코드 예제는 AWS SDK 구성 파일에 저장된 기본 자격 증명을 사용합니다. 구성 파일 생성에 대한 자세한 내용은 AWS CLI 설정을 참조하세요.

이 작업에 대한 자세한 내용은 DeleteLexicon API 참조를 참조하세요.

from argparse import ArgumentParser from sys import version_info from boto3 import Session from botocore.exceptions import BotoCoreError, ClientError # Define and parse the command line arguments cli = ArgumentParser(description="DeleteLexicon example") cli.add_argument("name", type=str, metavar="LEXICON_NAME") arguments = cli.parse_args() # 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") # Request confirmation prompt = input if version_info >= (3, 0) else raw_input proceed = prompt((u"This will delete the \"{0}\" lexicon," " do you want to proceed? [y,n]: ").format(arguments.name)) if proceed in ("y", "Y"): print(u"Deleting {0}...".format(arguments.name)) try: # Request deletion of a lexicon by name response = polly.delete_lexicon(Name=arguments.name) except (BotoCoreError, ClientError) as error: # The service returned an error, exit gracefully cli.error(error) print("Done.") else: print("Cancelled.")