Class: ElevenlabsClient::Voices
- Inherits:
-
Object
- Object
- ElevenlabsClient::Voices
- Defined in:
- lib/elevenlabs_client/endpoints/voices.rb
Instance Method Summary collapse
-
#active?(voice_id) ⇒ Boolean
Check if a voice is active (exists in the voice list).
-
#add_pvc_samples(voice_id, audio_files, filenames, **options) ⇒ Array<Hash>
POST /v1/voices/pvc/voice_id/samples Add audio samples to a PVC voice Documentation: https://elevenlabs.io/docs/api-reference/voices/add-pvc-samples.
-
#banned?(voice_id) ⇒ Boolean
Check if a voice is banned (safety control).
-
#create(name, samples = [], **options) ⇒ Hash
(also: #create_voice)
POST /v1/voices/add Creates a new voice by cloning from audio samples Documentation: https://elevenlabs.io/docs/api-reference/voices/add-voice.
-
#create_ivc(name, audio_files, filenames, **options) ⇒ Hash
POST /v1/voices/add Creates a new IVC (Instant Voice Cloning) voice Documentation: https://elevenlabs.io/docs/api-reference/voices/add-voice.
-
#create_pvc(name, language, **options) ⇒ Hash
POST /v1/voices/pvc Creates a new PVC (Professional Voice Cloning) voice with metadata but no samples Documentation: https://elevenlabs.io/docs/api-reference/voices/create-pvc.
-
#delete(voice_id) ⇒ Hash
(also: #delete_voice)
DELETE /v1/voices/voice_id Deletes a voice from your account Documentation: https://elevenlabs.io/docs/api-reference/voices/delete-voice.
-
#delete_pvc_sample(voice_id, sample_id) ⇒ Hash
DELETE /v1/voices/pvc/voice_id/samples/sample_id Delete a sample from a PVC voice Documentation: https://elevenlabs.io/docs/api-reference/voices/delete-pvc-sample.
-
#edit(voice_id, samples = [], **options) ⇒ Hash
(also: #edit_voice)
POST /v1/voices/voice_id/edit Updates an existing voice Documentation: https://elevenlabs.io/docs/api-reference/voices/edit-voice.
-
#edit_settings(voice_id, **options) ⇒ Hash
(also: #update_settings)
POST /v1/voices/voice_id/settings/edit Edit settings for a specific voice Documentation: https://elevenlabs.io/docs/api-reference/voices/edit-settings.
-
#find_similar(audio_file, filename, **options) ⇒ Hash
(also: #similar_voices)
POST /v1/similar-voices Returns a list of shared voices similar to the provided audio sample Documentation: https://elevenlabs.io/docs/api-reference/voices/similar-voices.
-
#get(voice_id) ⇒ Hash
(also: #get_voice)
GET /v1/voices/voice_id Retrieves details about a single voice Documentation: https://elevenlabs.io/docs/api-reference/voices/get-voice.
-
#get_default_settings ⇒ Hash
(also: #default_settings)
GET /v1/voices/settings/default Gets the default settings for voices Documentation: https://elevenlabs.io/docs/api-reference/voices/default-settings.
-
#get_pvc_captcha(voice_id) ⇒ Hash
GET /v1/voices/pvc/voice_id/captcha Get captcha for PVC voice verification Documentation: https://elevenlabs.io/docs/api-reference/voices/get-pvc-captcha.
-
#get_pvc_sample_audio(voice_id, sample_id, **options) ⇒ Hash
GET /v1/voices/pvc/voice_id/samples/sample_id/audio Retrieve voice sample audio with or without noise removal Documentation: https://elevenlabs.io/docs/api-reference/voices/get-pvc-sample-audio.
-
#get_pvc_sample_waveform(voice_id, sample_id) ⇒ Hash
GET /v1/voices/pvc/voice_id/samples/sample_id/waveform Retrieve the visual waveform of a voice sample Documentation: https://elevenlabs.io/docs/api-reference/voices/get-pvc-waveform.
-
#get_pvc_separated_speaker_audio(voice_id, sample_id, speaker_id) ⇒ Hash
GET /v1/voices/pvc/voice_id/samples/sample_id/speakers/speaker_id/audio Retrieve separated audio for a specific speaker Documentation: https://elevenlabs.io/docs/api-reference/voices/get-separated-speaker-audio.
-
#get_pvc_speaker_separation_status(voice_id, sample_id) ⇒ Hash
GET /v1/voices/pvc/voice_id/samples/sample_id/speakers Retrieve speaker separation status and detected speakers Documentation: https://elevenlabs.io/docs/api-reference/voices/get-pvc-speakers.
-
#get_sample_audio(voice_id, sample_id) ⇒ String
GET /v1/voices/voice_id/samples/sample_id/audio Returns the audio corresponding to a sample attached to a voice Documentation: https://elevenlabs.io/docs/api-reference/voices/get-sample-audio.
-
#get_settings(voice_id) ⇒ Hash
(also: #voice_settings)
GET /v1/voices/voice_id/settings Returns the settings for a specific voice Documentation: https://elevenlabs.io/docs/api-reference/voices/get-settings.
-
#initialize(client) ⇒ Voices
constructor
A new instance of Voices.
-
#list ⇒ Hash
(also: #list_voices)
GET /v1/voices Retrieves all voices associated with your Elevenlabs account Documentation: https://elevenlabs.io/docs/api-reference/voices.
-
#request_pvc_verification(voice_id, verification_files, filenames, **options) ⇒ Hash
POST /v1/voices/pvc/voice_id/verification Request manual verification for a PVC voice Documentation: https://elevenlabs.io/docs/api-reference/voices/request-pvc-verification.
-
#start_pvc_speaker_separation(voice_id, sample_id) ⇒ Hash
POST /v1/voices/pvc/voice_id/samples/sample_id/separate-speakers Start speaker separation process for a sample Documentation: https://elevenlabs.io/docs/api-reference/voices/start-speaker-separation.
-
#train_pvc(voice_id, **options) ⇒ Hash
POST /v1/voices/pvc/voice_id/train Start PVC training process for a voice Documentation: https://elevenlabs.io/docs/api-reference/voices/train-pvc.
-
#update_pvc(voice_id, **options) ⇒ Hash
POST /v1/voices/pvc/voice_id Edit PVC voice metadata Documentation: https://elevenlabs.io/docs/api-reference/voices/update-pvc.
-
#update_pvc_sample(voice_id, sample_id, **options) ⇒ Hash
POST /v1/voices/pvc/voice_id/samples/sample_id Update a PVC voice sample - apply noise removal or select speaker Documentation: https://elevenlabs.io/docs/api-reference/voices/update-pvc-sample.
-
#verify_pvc_captcha(voice_id, recording_file, filename) ⇒ Hash
POST /v1/voices/pvc/voice_id/captcha Submit captcha verification for PVC voice Documentation: https://elevenlabs.io/docs/api-reference/voices/verify-pvc-captcha.
Constructor Details
#initialize(client) ⇒ Voices
Returns a new instance of Voices.
5 6 7 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 5 def initialize(client) @client = client end |
Instance Method Details
#active?(voice_id) ⇒ Boolean
Check if a voice is active (exists in the voice list)
495 496 497 498 499 500 501 502 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 495 def active?(voice_id) voices = list active_voice_ids = voices["voices"].map { |voice| voice["voice_id"] } active_voice_ids.include?(voice_id) rescue ElevenlabsClient::ValidationError, ElevenlabsClient::APIError, ElevenlabsClient::NotFoundError # If we can't get the voice list, assume it's not active false end |
#add_pvc_samples(voice_id, audio_files, filenames, **options) ⇒ Array<Hash>
POST /v1/voices/pvc/voice_id/samples Add audio samples to a PVC voice Documentation: https://elevenlabs.io/docs/api-reference/voices/add-pvc-samples
299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 299 def add_pvc_samples(voice_id, audio_files, filenames, **) endpoint = "/v1/voices/pvc/#{voice_id}/samples" payload = {} payload[:remove_background_noise] = [:remove_background_noise] unless [:remove_background_noise].nil? # Add audio files audio_files.each_with_index do |file, index| filename = filenames[index] || "audio_#{index}.mp3" payload["files[]"] = @client.file_part(file, filename) end @client.post_multipart(endpoint, payload) end |
#banned?(voice_id) ⇒ Boolean
Check if a voice is banned (safety control)
484 485 486 487 488 489 490 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 484 def banned?(voice_id) voice = get(voice_id) voice["safety_control"] == "BAN" rescue ElevenlabsClient::ValidationError, ElevenlabsClient::APIError, ElevenlabsClient::NotFoundError # If we can't get the voice, assume it's not banned false end |
#create(name, samples = [], **options) ⇒ Hash Also known as: create_voice
POST /v1/voices/add Creates a new voice by cloning from audio samples Documentation: https://elevenlabs.io/docs/api-reference/voices/add-voice
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 40 def create(name, samples = [], **) endpoint = "/v1/voices/add" # Build multipart payload payload = { "name" => name, "description" => [:description] || "" } # Add labels if provided if [:labels] [:labels].each do |key, value| payload["labels[#{key}]"] = value.to_s end end # Add sample files samples.each_with_index do |sample, index| payload["files"] = @client.file_part(sample, "audio/mpeg") end @client.post_multipart(endpoint, payload) end |
#create_ivc(name, audio_files, filenames, **options) ⇒ Hash
POST /v1/voices/add Creates a new IVC (Instant Voice Cloning) voice Documentation: https://elevenlabs.io/docs/api-reference/voices/add-voice
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 148 def create_ivc(name, audio_files, filenames, **) endpoint = "/v1/voices/add" payload = { name: name } # Add optional parameters payload[:remove_background_noise] = [:remove_background_noise] unless [:remove_background_noise].nil? payload[:description] = [:description] if [:description] payload[:labels] = [:labels] if [:labels] # Add audio files audio_files.each_with_index do |file, index| filename = filenames[index] || "audio_#{index}.mp3" payload["files[]"] = @client.file_part(file, filename) end @client.post_multipart(endpoint, payload) end |
#create_pvc(name, language, **options) ⇒ Hash
POST /v1/voices/pvc Creates a new PVC (Professional Voice Cloning) voice with metadata but no samples Documentation: https://elevenlabs.io/docs/api-reference/voices/create-pvc
235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 235 def create_pvc(name, language, **) endpoint = "/v1/voices/pvc" payload = { name: name, language: language } payload[:description] = [:description] if [:description] payload[:labels] = [:labels] if [:labels] @client.post(endpoint, payload) end |
#delete(voice_id) ⇒ Hash Also known as: delete_voice
DELETE /v1/voices/voice_id Deletes a voice from your account Documentation: https://elevenlabs.io/docs/api-reference/voices/delete-voice
108 109 110 111 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 108 def delete(voice_id) endpoint = "/v1/voices/#{voice_id}" @client.delete(endpoint) end |
#delete_pvc_sample(voice_id, sample_id) ⇒ Hash
DELETE /v1/voices/pvc/voice_id/samples/sample_id Delete a sample from a PVC voice Documentation: https://elevenlabs.io/docs/api-reference/voices/delete-pvc-sample
345 346 347 348 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 345 def delete_pvc_sample(voice_id, sample_id) endpoint = "/v1/voices/pvc/#{voice_id}/samples/#{sample_id}" @client.delete(endpoint) end |
#edit(voice_id, samples = [], **options) ⇒ Hash Also known as: edit_voice
POST /v1/voices/voice_id/edit Updates an existing voice Documentation: https://elevenlabs.io/docs/api-reference/voices/edit-voice
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 75 def edit(voice_id, samples = [], **) endpoint = "/v1/voices/#{voice_id}/edit" # Build multipart payload payload = {} # Add text fields if provided payload["name"] = [:name] if [:name] payload["description"] = [:description] if [:description] # Add labels if provided if [:labels] [:labels].each do |key, value| payload["labels[#{key}]"] = value.to_s end end # Add sample files if provided if samples && !samples.empty? samples.each_with_index do |sample, index| payload["files"] = @client.file_part(sample, "audio/mpeg") end end @client.post_multipart(endpoint, payload) end |
#edit_settings(voice_id, **options) ⇒ Hash Also known as: update_settings
POST /v1/voices/voice_id/settings/edit Edit settings for a specific voice Documentation: https://elevenlabs.io/docs/api-reference/voices/edit-settings
200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 200 def edit_settings(voice_id, **) endpoint = "/v1/voices/#{voice_id}/settings/edit" payload = {} payload[:stability] = [:stability] if [:stability] payload[:use_speaker_boost] = [:use_speaker_boost] unless [:use_speaker_boost].nil? payload[:similarity_boost] = [:similarity_boost] if [:similarity_boost] payload[:style] = [:style] if [:style] payload[:speed] = [:speed] if [:speed] @client.post(endpoint, payload) end |
#find_similar(audio_file, filename, **options) ⇒ Hash Also known as: similar_voices
POST /v1/similar-voices Returns a list of shared voices similar to the provided audio sample Documentation: https://elevenlabs.io/docs/api-reference/voices/similar-voices
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 123 def find_similar(audio_file, filename, **) endpoint = "/v1/similar-voices" payload = { audio_file: @client.file_part(audio_file, filename) } payload[:similarity_threshold] = [:similarity_threshold] if [:similarity_threshold] payload[:top_k] = [:top_k] if [:top_k] @client.post_multipart(endpoint, payload) end |
#get(voice_id) ⇒ Hash Also known as: get_voice
GET /v1/voices/voice_id Retrieves details about a single voice Documentation: https://elevenlabs.io/docs/api-reference/voices/get-voice
15 16 17 18 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 15 def get(voice_id) endpoint = "/v1/voices/#{voice_id}" @client.get(endpoint) end |
#get_default_settings ⇒ Hash Also known as: default_settings
GET /v1/voices/settings/default Gets the default settings for voices Documentation: https://elevenlabs.io/docs/api-reference/voices/default-settings
172 173 174 175 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 172 def get_default_settings endpoint = "/v1/voices/settings/default" @client.get(endpoint) end |
#get_pvc_captcha(voice_id) ⇒ Hash
GET /v1/voices/pvc/voice_id/captcha Get captcha for PVC voice verification Documentation: https://elevenlabs.io/docs/api-reference/voices/get-pvc-captcha
448 449 450 451 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 448 def get_pvc_captcha(voice_id) endpoint = "/v1/voices/pvc/#{voice_id}/captcha" @client.get(endpoint) end |
#get_pvc_sample_audio(voice_id, sample_id, **options) ⇒ Hash
GET /v1/voices/pvc/voice_id/samples/sample_id/audio Retrieve voice sample audio with or without noise removal Documentation: https://elevenlabs.io/docs/api-reference/voices/get-pvc-sample-audio
359 360 361 362 363 364 365 366 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 359 def get_pvc_sample_audio(voice_id, sample_id, **) endpoint = "/v1/voices/pvc/#{voice_id}/samples/#{sample_id}/audio" params = {} params[:remove_background_noise] = [:remove_background_noise] unless [:remove_background_noise].nil? @client.get(endpoint, params) end |
#get_pvc_sample_waveform(voice_id, sample_id) ⇒ Hash
GET /v1/voices/pvc/voice_id/samples/sample_id/waveform Retrieve the visual waveform of a voice sample Documentation: https://elevenlabs.io/docs/api-reference/voices/get-pvc-waveform
375 376 377 378 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 375 def get_pvc_sample_waveform(voice_id, sample_id) endpoint = "/v1/voices/pvc/#{voice_id}/samples/#{sample_id}/waveform" @client.get(endpoint) end |
#get_pvc_separated_speaker_audio(voice_id, sample_id, speaker_id) ⇒ Hash
GET /v1/voices/pvc/voice_id/samples/sample_id/speakers/speaker_id/audio Retrieve separated audio for a specific speaker Documentation: https://elevenlabs.io/docs/api-reference/voices/get-separated-speaker-audio
412 413 414 415 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 412 def get_pvc_separated_speaker_audio(voice_id, sample_id, speaker_id) endpoint = "/v1/voices/pvc/#{voice_id}/samples/#{sample_id}/speakers/#{speaker_id}/audio" @client.get(endpoint) end |
#get_pvc_speaker_separation_status(voice_id, sample_id) ⇒ Hash
GET /v1/voices/pvc/voice_id/samples/sample_id/speakers Retrieve speaker separation status and detected speakers Documentation: https://elevenlabs.io/docs/api-reference/voices/get-pvc-speakers
387 388 389 390 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 387 def get_pvc_speaker_separation_status(voice_id, sample_id) endpoint = "/v1/voices/pvc/#{voice_id}/samples/#{sample_id}/speakers" @client.get(endpoint) end |
#get_sample_audio(voice_id, sample_id) ⇒ String
GET /v1/voices/voice_id/samples/sample_id/audio Returns the audio corresponding to a sample attached to a voice Documentation: https://elevenlabs.io/docs/api-reference/voices/get-sample-audio
220 221 222 223 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 220 def get_sample_audio(voice_id, sample_id) endpoint = "/v1/voices/#{voice_id}/samples/#{sample_id}/audio" @client.get(endpoint) end |
#get_settings(voice_id) ⇒ Hash Also known as: voice_settings
GET /v1/voices/voice_id/settings Returns the settings for a specific voice Documentation: https://elevenlabs.io/docs/api-reference/voices/get-settings
183 184 185 186 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 183 def get_settings(voice_id) endpoint = "/v1/voices/#{voice_id}/settings" @client.get(endpoint) end |
#list ⇒ Hash Also known as: list_voices
GET /v1/voices Retrieves all voices associated with your Elevenlabs account Documentation: https://elevenlabs.io/docs/api-reference/voices
25 26 27 28 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 25 def list endpoint = "/v1/voices" @client.get(endpoint) end |
#request_pvc_verification(voice_id, verification_files, filenames, **options) ⇒ Hash
POST /v1/voices/pvc/voice_id/verification Request manual verification for a PVC voice Documentation: https://elevenlabs.io/docs/api-reference/voices/request-pvc-verification
427 428 429 430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 427 def request_pvc_verification(voice_id, verification_files, filenames, **) endpoint = "/v1/voices/pvc/#{voice_id}/verification" payload = {} payload[:extra_text] = [:extra_text] if [:extra_text] # Add verification files verification_files.each_with_index do |file, index| filename = filenames[index] || "verification_#{index}.pdf" payload["files[]"] = @client.file_part(file, filename) end @client.post_multipart(endpoint, payload) end |
#start_pvc_speaker_separation(voice_id, sample_id) ⇒ Hash
POST /v1/voices/pvc/voice_id/samples/sample_id/separate-speakers Start speaker separation process for a sample Documentation: https://elevenlabs.io/docs/api-reference/voices/start-speaker-separation
399 400 401 402 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 399 def start_pvc_speaker_separation(voice_id, sample_id) endpoint = "/v1/voices/pvc/#{voice_id}/samples/#{sample_id}/separate-speakers" @client.post(endpoint) end |
#train_pvc(voice_id, **options) ⇒ Hash
POST /v1/voices/pvc/voice_id/train Start PVC training process for a voice Documentation: https://elevenlabs.io/docs/api-reference/voices/train-pvc
280 281 282 283 284 285 286 287 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 280 def train_pvc(voice_id, **) endpoint = "/v1/voices/pvc/#{voice_id}/train" payload = {} payload[:model_id] = [:model_id] if [:model_id] @client.post(endpoint, payload) end |
#update_pvc(voice_id, **options) ⇒ Hash
POST /v1/voices/pvc/voice_id Edit PVC voice metadata Documentation: https://elevenlabs.io/docs/api-reference/voices/update-pvc
260 261 262 263 264 265 266 267 268 269 270 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 260 def update_pvc(voice_id, **) endpoint = "/v1/voices/pvc/#{voice_id}" payload = {} payload[:name] = [:name] if [:name] payload[:language] = [:language] if [:language] payload[:description] = [:description] if [:description] payload[:labels] = [:labels] if [:labels] @client.post(endpoint, payload) end |
#update_pvc_sample(voice_id, sample_id, **options) ⇒ Hash
POST /v1/voices/pvc/voice_id/samples/sample_id Update a PVC voice sample - apply noise removal or select speaker Documentation: https://elevenlabs.io/docs/api-reference/voices/update-pvc-sample
326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 326 def update_pvc_sample(voice_id, sample_id, **) endpoint = "/v1/voices/pvc/#{voice_id}/samples/#{sample_id}" payload = {} payload[:remove_background_noise] = [:remove_background_noise] unless [:remove_background_noise].nil? payload[:selected_speaker_ids] = [:selected_speaker_ids] if [:selected_speaker_ids] payload[:trim_start_time] = [:trim_start_time] if [:trim_start_time] payload[:trim_end_time] = [:trim_end_time] if [:trim_end_time] @client.post(endpoint, payload) end |
#verify_pvc_captcha(voice_id, recording_file, filename) ⇒ Hash
POST /v1/voices/pvc/voice_id/captcha Submit captcha verification for PVC voice Documentation: https://elevenlabs.io/docs/api-reference/voices/verify-pvc-captcha
461 462 463 464 465 466 467 468 469 |
# File 'lib/elevenlabs_client/endpoints/voices.rb', line 461 def verify_pvc_captcha(voice_id, recording_file, filename) endpoint = "/v1/voices/pvc/#{voice_id}/captcha" payload = { recording: @client.file_part(recording_file, filename) } @client.post_multipart(endpoint, payload) end |