本文整理汇总了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;
}