Amazon Polly
Developer Guide


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; import; import; public class PutLexiconSample { AmazonPolly client = AmazonPollyClientBuilder.defaultClient(); private String LEXICON_CONTENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<lexicon version=\"1.0\" xmlns=\"\" xmlns:xsi=\"\" " + "xsi:schemaLocation=\"\" " + "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); } } }