Class: ElevenlabsClient::TextToVoice
- Inherits:
-
Object
- Object
- ElevenlabsClient::TextToVoice
- Defined in:
- lib/elevenlabs_client/endpoints/text_to_voice.rb
Instance Method Summary collapse
-
#create(voice_name, voice_description, generated_voice_id, **options) ⇒ Hash
(also: #create_from_generated_voice)
POST /v1/text-to-voice Creates a voice from the designed voice generated_voice_id Documentation: https://elevenlabs.io/docs/api-reference/text-to-voice.
-
#design(voice_description, **options) ⇒ Hash
(also: #design_voice)
POST /v1/text-to-voice/design Designs a voice based on a description Documentation: https://elevenlabs.io/docs/api-reference/text-to-voice/design.
-
#initialize(client) ⇒ TextToVoice
constructor
A new instance of TextToVoice.
-
#list_voices ⇒ Hash
GET /v1/voices Retrieves all voices associated with your Elevenlabs account Documentation: https://elevenlabs.io/docs/api-reference/voices.
-
#stream_preview(generated_voice_id, &block) ⇒ Faraday::Response
(also: #stream_voice_preview)
GET /v1/text-to-voice/:generated_voice_id/stream Stream a voice preview that was created via the /v1/text-to-voice/design endpoint Documentation: https://elevenlabs.io/docs/api-reference/text-to-voice/stream-voice-preview.
Constructor Details
#initialize(client) ⇒ TextToVoice
Returns a new instance of TextToVoice.
5 6 7 |
# File 'lib/elevenlabs_client/endpoints/text_to_voice.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#create(voice_name, voice_description, generated_voice_id, **options) ⇒ Hash Also known as: create_from_generated_voice
POST /v1/text-to-voice Creates a voice from the designed voice generated_voice_id Documentation: https://elevenlabs.io/docs/api-reference/text-to-voice
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/elevenlabs_client/endpoints/text_to_voice.rb', line 62 def create(voice_name, voice_description, generated_voice_id, **) endpoint = "/v1/text-to-voice" request_body = { voice_name: voice_name, voice_description: voice_description, generated_voice_id: generated_voice_id } # Add optional parameters if provided request_body[:labels] = [:labels] if [:labels] request_body[:played_not_selected_voice_ids] = [:played_not_selected_voice_ids] if [:played_not_selected_voice_ids] @client.post(endpoint, request_body) end |
#design(voice_description, **options) ⇒ Hash Also known as: design_voice
POST /v1/text-to-voice/design Designs a voice based on a description Documentation: https://elevenlabs.io/docs/api-reference/text-to-voice/design
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/elevenlabs_client/endpoints/text_to_voice.rb', line 29 def design(voice_description, **) endpoint = "/v1/text-to-voice/design" request_body = { voice_description: voice_description } # Add optional parameters if provided request_body[:output_format] = [:output_format] if [:output_format] request_body[:model_id] = [:model_id] if [:model_id] request_body[:text] = [:text] if [:text] request_body[:auto_generate_text] = [:auto_generate_text] unless [:auto_generate_text].nil? request_body[:loudness] = [:loudness] if [:loudness] request_body[:seed] = [:seed] if [:seed] request_body[:guidance_scale] = [:guidance_scale] if [:guidance_scale] request_body[:stream_previews] = [:stream_previews] unless [:stream_previews].nil? request_body[:remixing_session_id] = [:remixing_session_id] if [:remixing_session_id] request_body[:remixing_session_iteration_id] = [:remixing_session_iteration_id] if [:remixing_session_iteration_id] request_body[:quality] = [:quality] if [:quality] request_body[:reference_audio_base64] = [:reference_audio_base64] if [:reference_audio_base64] request_body[:prompt_strength] = [:prompt_strength] if [:prompt_strength] @client.post(endpoint, request_body) end |
#list_voices ⇒ Hash
GET /v1/voices Retrieves all voices associated with your Elevenlabs account Documentation: https://elevenlabs.io/docs/api-reference/voices
94 95 96 97 |
# File 'lib/elevenlabs_client/endpoints/text_to_voice.rb', line 94 def list_voices endpoint = "/v1/voices" @client.get(endpoint) end |
#stream_preview(generated_voice_id, &block) ⇒ Faraday::Response Also known as: stream_voice_preview
GET /v1/text-to-voice/:generated_voice_id/stream Stream a voice preview that was created via the /v1/text-to-voice/design endpoint Documentation: https://elevenlabs.io/docs/api-reference/text-to-voice/stream-voice-preview
84 85 86 87 |
# File 'lib/elevenlabs_client/endpoints/text_to_voice.rb', line 84 def stream_preview(generated_voice_id, &block) endpoint = "/v1/text-to-voice/#{generated_voice_id}/stream" @client.get_streaming(endpoint, &block) end |