Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

PutLexicon

Focus mode
PutLexicon - Amazon Polly

The following Java code sample show how to use Java-based applications to store a pronunciation lexicon in an AWS Region.

For more information on this operation, see the reference for the PutLexicon API.

package com.amazonaws.polly.samples; import com.amazonaws.services.polly.AmazonPolly; import com.amazonaws.services.polly.AmazonPollyClientBuilder; import com.amazonaws.services.polly.model.PutLexiconRequest; public class PutLexiconSample { AmazonPolly client = AmazonPollyClientBuilder.defaultClient(); private String LEXICON_CONTENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<lexicon version=\"1.0\" xmlns=\"http://www.w3.org/2005/01/pronunciation-lexicon\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xsi:schemaLocation=\"http://www.w3.org/2005/01/pronunciation-lexicon http://www.w3.org/TR/2007/CR-pronunciation-lexicon-20071212/pls.xsd\" " + "alphabet=\"ipa\" xml:lang=\"en-US\">" + "<lexeme><grapheme>test1</grapheme><alias>test2</alias></lexeme>" + "</lexicon>"; private String LEXICON_NAME = "SampleLexicon"; public void putLexicon() { PutLexiconRequest putLexiconRequest = new PutLexiconRequest() .withContent(LEXICON_CONTENT) .withName(LEXICON_NAME); try { client.putLexicon(putLexiconRequest); } catch (Exception e) { System.err.println("Exception caught: " + e); } } }
PrivacySite termsCookie preferences
© 2025, Amazon Web Services, Inc. or its affiliates. All rights reserved.