Getting a List of Voices - AWS SDK for Ruby

Getting a List of Voices

This example uses the describe_voices method to get the list of US English voices in the us-west-2 region.

Choose Copy to save the code locally.

Create the file polly_describe_voices.rb.

Add the required gem.


Version 2 of the AWS SDK for Ruby didn’t have service-specific gems.

# Copyright 2010-2019, Inc. or its affiliates. All Rights Reserved. # # This file is licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. A copy of the # License is located at # # # # This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS # OF ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. require 'aws-sdk-polly' # In v2: require 'aws-sdk' begin # Create an Amazon Polly client using # credentials from the shared credentials file ~/.aws/credentials # and the configuration (region) from the shared configuration file ~/.aws/config polly = # Get US English voices resp = polly.describe_voices(language_code: 'en-US') resp.voices.each do |v| puts puts ' ' + v.gender puts end rescue StandardError => ex puts 'Could not get voices' puts 'Error message:' puts ex.message end

See the complete example on GitHub.