Class: Telnyx::Resources::TextToSpeech
- Inherits:
-
Object
- Object
- Telnyx::Resources::TextToSpeech
- Defined in:
- lib/telnyx/resources/text_to_speech.rb
Instance Method Summary collapse
-
#generate_speech(text:, voice:, request_options: {}) ⇒ StringIO
Some parameter documentations has been truncated, see Models::TextToSpeechGenerateSpeechParams for more details.
-
#initialize(client:) ⇒ TextToSpeech
constructor
private
A new instance of TextToSpeech.
-
#list_voices(elevenlabs_api_key_ref: nil, provider: nil, request_options: {}) ⇒ Telnyx::Models::TextToSpeechListVoicesResponse
Returns a list of voices that can be used with the text to speech commands.
Constructor Details
#initialize(client:) ⇒ TextToSpeech
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of TextToSpeech.
62 63 64 |
# File 'lib/telnyx/resources/text_to_speech.rb', line 62 def initialize(client:) @client = client end |
Instance Method Details
#generate_speech(text:, voice:, request_options: {}) ⇒ StringIO
Some parameter documentations has been truncated, see Models::TextToSpeechGenerateSpeechParams for more details.
Converts the provided text to speech using the specified voice and returns audio data
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/telnyx/resources/text_to_speech.rb', line 23 def generate_speech(params) parsed, = Telnyx::TextToSpeechGenerateSpeechParams.dump_request(params) @client.request( method: :post, path: "text-to-speech/speech", headers: {"accept" => "audio/mpeg"}, body: parsed, model: StringIO, options: ) end |
#list_voices(elevenlabs_api_key_ref: nil, provider: nil, request_options: {}) ⇒ Telnyx::Models::TextToSpeechListVoicesResponse
Returns a list of voices that can be used with the text to speech commands.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/telnyx/resources/text_to_speech.rb', line 48 def list_voices(params = {}) parsed, = Telnyx::TextToSpeechListVoicesParams.dump_request(params) @client.request( method: :get, path: "text-to-speech/voices", query: parsed, model: Telnyx::Models::TextToSpeechListVoicesResponse, options: ) end |