- AWS Code Sample demonstrates how to delete a lexicon in the region specified in your local AWS configuration..

# Copyright 2010-2019, Inc. or its affiliates. All Rights Reserved. # # This file is licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. A copy of the # License is located at # # # # This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS # OF ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. 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( if proceed in ("y", "Y"): print(u"Deleting {0}...".format( try: # Request deletion of a lexicon by name response = polly.delete_lexicon( except (BotoCoreError, ClientError) as error: # The service returned an error, exit gracefully cli.error(error) print("Done.") else: print("Cancelled.")

Sample Details

Service: polly

Last tested: 2019-01-31

Author: (AWS)

Type: full-example