Class: ElevenlabsClient::Admin::VoiceLibrary

Inherits:
Object
  • Object
show all
Defined in:
lib/elevenlabs_client/endpoints/admin/voice_library.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ VoiceLibrary

Returns a new instance of VoiceLibrary.



6
7
8
# File 'lib/elevenlabs_client/endpoints/admin/voice_library.rb', line 6

def initialize(client)
  @client = client
end

Instance Method Details

#add_shared_voice(public_user_id:, voice_id:, new_name:) ⇒ Hash Also known as: add_voice

POST /v1/voices/add/:public_user_id/:voice_id Add a shared voice to your collection of voices Documentation: https://elevenlabs.io/docs/api-reference/shared-voices/add-shared-voice

Parameters:

  • public_user_id (String)

    Public user ID used to publicly identify ElevenLabs users

  • voice_id (String)

    ID of the voice to be used

  • new_name (String)

    The name that identifies this voice

Returns:

  • (Hash)

    The JSON response containing the voice_id



67
68
69
70
71
72
73
74
75
# File 'lib/elevenlabs_client/endpoints/admin/voice_library.rb', line 67

def add_shared_voice(public_user_id:, voice_id:, new_name:)
  endpoint = "/v1/voices/add/#{public_user_id}/#{voice_id}"
  
  body = {
    new_name: new_name
  }
  
  @client.post(endpoint, body)
end

#get_shared_voices(page_size: nil, category: nil, gender: nil, age: nil, accent: nil, language: nil, locale: nil, search: nil, use_cases: nil, descriptives: nil, featured: nil, min_notice_period_days: nil, include_custom_rates: nil, include_live_moderated: nil, reader_app_enabled: nil, owner_id: nil, sort: nil, page: nil) ⇒ Hash Also known as: shared_voices, list_shared_voices

GET /v1/shared-voices Retrieves a list of shared voices Documentation: https://elevenlabs.io/docs/api-reference/shared-voices/get-shared-voices

Parameters:

  • page_size (Integer) (defaults to: nil)

    How many shared voices to return at maximum. Cannot exceed 100, defaults to 30

  • category (String) (defaults to: nil)

    Voice category used for filtering ("professional", "famous", "high_quality")

  • gender (String, nil) (defaults to: nil)

    Gender used for filtering

  • age (String, nil) (defaults to: nil)

    Age used for filtering

  • accent (String, nil) (defaults to: nil)

    Accent used for filtering

  • language (String, nil) (defaults to: nil)

    Language used for filtering

  • locale (String, nil) (defaults to: nil)

    Locale used for filtering

  • search (String, nil) (defaults to: nil)

    Search term used for filtering

  • use_cases (Array<String>, nil) (defaults to: nil)

    Use-case used for filtering

  • descriptives (Array<String>, nil) (defaults to: nil)

    Descriptive terms used for filtering

  • featured (Boolean) (defaults to: nil)

    Filter featured voices (defaults to false)

  • min_notice_period_days (Integer, nil) (defaults to: nil)

    Filter voices with a minimum notice period

  • include_custom_rates (Boolean, nil) (defaults to: nil)

    Include/exclude voices with custom rates

  • include_live_moderated (Boolean, nil) (defaults to: nil)

    Include/exclude voices that are live moderated

  • reader_app_enabled (Boolean) (defaults to: nil)

    Filter voices that are enabled for the reader app (defaults to false)

  • owner_id (String, nil) (defaults to: nil)

    Filter voices by public owner ID

  • sort (String, nil) (defaults to: nil)

    Sort criteria

  • page (Integer) (defaults to: nil)

    Page number (defaults to 0)

Returns:

  • (Hash)

    The JSON response containing voices array and pagination info



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/elevenlabs_client/endpoints/admin/voice_library.rb', line 33

def get_shared_voices(page_size: nil, category: nil, gender: nil, age: nil, accent: nil, language: nil, locale: nil, search: nil, use_cases: nil, descriptives: nil, featured: nil, min_notice_period_days: nil, include_custom_rates: nil, include_live_moderated: nil, reader_app_enabled: nil, owner_id: nil, sort: nil, page: nil)
  endpoint = "/v1/shared-voices"
  
  params = {}
  params[:page_size] = page_size if page_size
  params[:category] = category if category
  params[:gender] = gender if gender
  params[:age] = age if age
  params[:accent] = accent if accent
  params[:language] = language if language
  params[:locale] = locale if locale
  params[:search] = search if search
  params[:use_cases] = use_cases if use_cases
  params[:descriptives] = descriptives if descriptives
  params[:featured] = featured unless featured.nil?
  params[:min_notice_period_days] = min_notice_period_days if min_notice_period_days
  params[:include_custom_rates] = include_custom_rates unless include_custom_rates.nil?
  params[:include_live_moderated] = include_live_moderated unless include_live_moderated.nil?
  params[:reader_app_enabled] = reader_app_enabled unless reader_app_enabled.nil?
  params[:owner_id] = owner_id if owner_id
  params[:sort] = sort if sort
  params[:page] = page if page
  
  @client.get(endpoint, params)
end