Example usage for com.amazonaws.services.polly.model DescribeVoicesRequest DescribeVoicesRequest

List of usage examples for com.amazonaws.services.polly.model DescribeVoicesRequest DescribeVoicesRequest

Introduction

In this page you can find the example usage for com.amazonaws.services.polly.model DescribeVoicesRequest DescribeVoicesRequest.

Prototype

DescribeVoicesRequest

Source Link

Usage

From source file:com.github.gregwhitaker.awspolly.example.PollyVoicesHandler.java

License:Apache License

@Override
public void handle(Context ctx) throws Exception {
    String token = null;//from w ww. jav a  2  s  .  c om
    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;
        }
    }
}

From source file:org.openhab.voice.pollytts.internal.cloudapi.PollyTTSCloudImpl.java

License:Open Source License

public PollyTTSCloudImpl(PollyTTSConfig config) {
    this.config = config;

    AWSCredentials credentials = new BasicAWSCredentials(config.getAccessKey(), config.getSecretKey());
    client = AmazonPollyClientBuilder.standard().withRegion(config.getServiceRegion())
            .withCredentials(new AWSStaticCredentialsProvider(credentials)).build();
    voices = client.describeVoices(new DescribeVoicesRequest()).getVoices();

    // create voice to ID translation for service invocation
    labelToID = voices.stream().collect(toMap(Voice::getName, Voice::getId));
}