本文整理匯總了Java中com.amazonaws.services.polly.model.DescribeVoicesResult類的典型用法代碼示例。如果您正苦於以下問題:Java DescribeVoicesResult類的具體用法?Java DescribeVoicesResult怎麽用?Java DescribeVoicesResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DescribeVoicesResult類屬於com.amazonaws.services.polly.model包,在下文中一共展示了DescribeVoicesResult類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handle
import com.amazonaws.services.polly.model.DescribeVoicesResult; //導入依賴的package包/類
@Override
public void handle(Context ctx) throws Exception {
String token = null;
List<Voice> voices = new ArrayList<>();
while (true) {
DescribeVoicesResult result;
if (token == null) {
result = polly.describeVoices(new DescribeVoicesRequest());
} else {
result = polly.describeVoices(new DescribeVoicesRequest().withNextToken(token));
}
voices.addAll(result.getVoices());
if (result.getNextToken() != null) {
token = result.getNextToken();
} else {
ctx.render(Jackson.toJsonString(voices));
break;
}
}
}
示例2: processVoicesRequest
import com.amazonaws.services.polly.model.DescribeVoicesResult; //導入依賴的package包/類
private void processVoicesRequest() {
// Create describe voices request.
DescribeVoicesRequest describeVoicesRequest = new DescribeVoicesRequest();
// Synchronously ask Polly Polly to describe available TTS voices.
DescribeVoicesResult describeVoicesResult = polly.describeVoices(describeVoicesRequest);
awsVoices = describeVoicesResult.getVoices();
log.info("found {} voices", awsVoices.size());
for (int i = 0; i < awsVoices.size(); ++i) {
Voice voice = awsVoices.get(i);
voiceMap.put(voice.getName(), voice);
langMap.put(voice.getLanguageCode(), voice);
log.info("{} {} - {}", i, voice.getName(), voice.getLanguageCode());
}
// set default voice
if (voice == null) {
voice = awsVoices.get(0).getName();
awsVoice = awsVoices.get(0);
lang = awsVoice.getLanguageCode();
log.info("setting default voice to {}", voice);
}
}
示例3: doInBackground
import com.amazonaws.services.polly.model.DescribeVoicesResult; //導入依賴的package包/類
@Override
protected Void doInBackground(Void... params) {
if (voices != null) {
return null;
}
// Create describe voices request.
DescribeVoicesRequest describeVoicesRequest = new DescribeVoicesRequest();
DescribeVoicesResult describeVoicesResult;
try {
// Synchronously ask the Polly Service to describe available TTS voices.
describeVoicesResult = client.describeVoices(describeVoicesRequest);
} catch (RuntimeException e) {
Log.e(TAG, "Unable to get available voices. " + e.getMessage());
return null;
}
// Get list of voices from the result.
voices = describeVoicesResult.getVoices();
// Log a message with a list of available TTS voices.
Log.i(TAG, "Available Polly voices: " + voices);
return null;
}