- AWS Code Sample

ListLexicons demonstrates how to produce a list of pronunciation lexicons stored in an AWS Region.

/** * Copyright, 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. */ package com.example.polly; import; import; import; import; import; import ; import java.util.Iterator; import java.util.List; public class ListLexicons { public static void main(String args[]) { PollyClient polly = PollyClient.builder() .region(Region.US_WEST_2) .build(); listLexicons(polly) ; } public static void listLexicons(PollyClient client) { try { ListLexiconsRequest listLexiconsRequest = ListLexiconsRequest.builder() .build(); ListLexiconsResponse listLexiconsResult = client.listLexicons(listLexiconsRequest); List<LexiconDescription> lexiconDescription = listLexiconsResult.lexicons(); Iterator<LexiconDescription> iterator = lexiconDescription.iterator(); // Get each voice while (iterator.hasNext()) { LexiconDescription lexDescription =; System.out.println("The name of the lexicon is "; } } catch (PollyException e) { System.err.println("Exception caught: " + e); System.exit(1); } } }

Sample Details

Service: Amazon Polly

Last tested: 5/7/2020

Author: scmacdon AWS

Type: full-example