Java 类com.amazonaws.services.polly.model.DescribeVoicesResult 实例源码

项目:aws-polly-example    文件:PollyVoicesHandler.java   
@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;
        }
    }
}
项目:myrobotlab    文件:Polly.java   
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);
  }

}
项目:aws-sdk-android-samples    文件:MainActivity.java   
@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;
}