GetLexicon - Amazon Polly

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

GetLexicon

下列 Java 程式碼範例示範如何使用 Java 型應用程式來產生儲存在 AWS 區域中的特定發音詞庫的內容。

如需此操作的詳細資訊,請參閱 GetLexicon 的參考API。

package com.amazonaws.polly.samples; import com.amazonaws.services.polly.AmazonPolly; import com.amazonaws.services.polly.AmazonPollyClientBuilder; import com.amazonaws.services.polly.model.GetLexiconRequest; import com.amazonaws.services.polly.model.GetLexiconResult; public class GetLexiconSample { private String LEXICON_NAME = "SampleLexicon"; AmazonPolly client = AmazonPollyClientBuilder.defaultClient(); public void getLexicon() { GetLexiconRequest getLexiconRequest = new GetLexiconRequest().withName(LEXICON_NAME); try { GetLexiconResult getLexiconResult = client.getLexicon(getLexiconRequest); System.out.println("Lexicon: " + getLexiconResult.getLexicon()); } catch (Exception e) { System.err.println("Exception caught: " + e); } } }