Class: Telnyx::Resources::TextToSpeech

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/text_to_speech.rb

Overview

Text to speech streaming command operations

Instance Method Summary collapse

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.

Parameters:



109
110
111
# File 'lib/telnyx/resources/text_to_speech.rb', line 109

def initialize(client:)
  @client = client
end

Instance Method Details

#generate(aws: nil, azure: nil, disable_cache: nil, elevenlabs: nil, language: nil, minimax: nil, output_type: nil, provider: nil, resemble: nil, rime: nil, telnyx: nil, text: nil, text_type: nil, voice: nil, voice_settings: nil, request_options: {}) ⇒ Telnyx::Models::TextToSpeechGenerateResponse

Some parameter documentations has been truncated, see Models::TextToSpeechGenerateParams for more details.

Generate synthesized speech audio from text input. Returns audio in the requested format (binary audio stream, base64-encoded JSON, or an audio URL for later retrieval).

Authentication is provided via the standard ‘Authorization: Bearer <API_KEY>` header.

The ‘voice` parameter provides a convenient shorthand to specify provider, model, and voice in a single string (e.g. `telnyx.NaturalHD.Alloy` or `Telnyx.Ultra.<voice_id>`). Alternatively, specify `provider` explicitly along with provider-specific parameters.

Supported providers: ‘aws`, `telnyx`, `azure`, `elevenlabs`, `minimax`, `rime`, `resemble`.

The Telnyx ‘Ultra` model supports 44 languages with emotion control, speed adjustment, and volume control. Use the `telnyx` provider-specific parameters to configure these features.

Parameters:

Returns:

See Also:



66
67
68
69
70
71
72
73
74
75
# File 'lib/telnyx/resources/text_to_speech.rb', line 66

def generate(params = {})
  parsed, options = Telnyx::TextToSpeechGenerateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "text-to-speech/speech",
    body: parsed,
    model: Telnyx::Models::TextToSpeechGenerateResponse,
    options: options
  )
end

#list_voices(api_key: nil, provider: nil, request_options: {}) ⇒ Telnyx::Models::TextToSpeechListVoicesResponse

Retrieve a list of available voices from one or all TTS providers. When ‘provider` is specified, returns voices for that provider only. Otherwise, returns voices from all providers.

Some providers (ElevenLabs, Resemble) require an API key to list voices.

Parameters:

Returns:

See Also:



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/telnyx/resources/text_to_speech.rb', line 94

def list_voices(params = {})
  parsed, options = Telnyx::TextToSpeechListVoicesParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "text-to-speech/voices",
    query: query,
    model: Telnyx::Models::TextToSpeechListVoicesResponse,
    options: options
  )
end