當前位置: 首頁>>代碼示例>>Java>>正文


Java DescribeVoicesResult類代碼示例

本文整理匯總了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;
        }
    }
}
 
開發者ID:gregwhitaker,項目名稱:aws-polly-example,代碼行數:24,代碼來源:PollyVoicesHandler.java

示例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);
  }

}
 
開發者ID:MyRobotLab,項目名稱:myrobotlab,代碼行數:25,代碼來源:Polly.java

示例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;
}
 
開發者ID:awslabs,項目名稱:aws-sdk-android-samples,代碼行數:27,代碼來源:MainActivity.java


注:本文中的com.amazonaws.services.polly.model.DescribeVoicesResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。