Obter uma lista de vozes - AWS SDK para Ruby

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

Obter uma lista de vozes

Este exemplo usa o método describe_voices para obter a lista de vozes em inglês dos EUA na região us-west-2.

Escolha Copy para salvar o código localmente.

Crie o arquivo polly_describe_voices.rb.

Adicione o gem necessário.

nota

A versão 2 do AWS SDK para Ruby não tinha gems específicos do serviço.

# Copyright 2010-2019 Amazon.com, 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 # # http://aws.amazon.com/apache2.0/ # # 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 = Aws::Polly::Client.new # Get US English voices resp = polly.describe_voices(language_code: 'en-US') resp.voices.each do |v| puts v.name puts ' ' + v.gender puts end rescue StandardError => ex puts 'Could not get voices' puts 'Error message:' puts ex.message end

Veja o exemplo completo no GitHub.