Class: ElevenlabsClient::AudioNative

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

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ AudioNative

Returns a new instance of AudioNative.



5
6
7
# File 'lib/elevenlabs_client/endpoints/audio_native.rb', line 5

def initialize(client)
  @client = client
end

Instance Method Details

#create(name, **options) ⇒ Hash Also known as: create_project

POST /v1/audio-native Creates Audio Native enabled project, optionally starts conversion and returns project ID and embeddable HTML snippet Documentation: https://elevenlabs.io/docs/api-reference/audio-native/create

Parameters:

  • name (String)

    Project name

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :image (String)

    Image URL used in the player (deprecated)

  • :author (String)

    Author used in the player

  • :title (String)

    Title used in the player

  • :small (Boolean)

    Whether to use small player (deprecated, defaults to false)

  • :text_color (String)

    Text color used in the player

  • :background_color (String)

    Background color used in the player

  • :sessionization (Integer)

    Minutes to persist session (deprecated, defaults to 0)

  • :voice_id (String)

    Voice ID used to voice the content

  • :model_id (String)

    TTS Model ID used in the player

  • :file (IO, File)

    Text or HTML input file containing article content

  • :filename (String)

    Original filename for the file

  • :auto_convert (Boolean)

    Whether to auto convert project to audio (defaults to false)

  • :apply_text_normalization (String)

    Text normalization mode ('auto', 'on', 'off', 'apply_english')

Returns:

  • (Hash)

    JSON response containing project_id, converting status, and html_snippet



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/elevenlabs_client/endpoints/audio_native.rb', line 29

def create(name, **options)
  endpoint = "/v1/audio-native"
  
  payload = { name: name }
  
  # Add optional parameters if provided
  payload[:image] = options[:image] if options[:image]
  payload[:author] = options[:author] if options[:author]
  payload[:title] = options[:title] if options[:title]
  payload[:small] = options[:small] unless options[:small].nil?
  payload[:text_color] = options[:text_color] if options[:text_color]
  payload[:background_color] = options[:background_color] if options[:background_color]
  payload[:sessionization] = options[:sessionization] if options[:sessionization]
  payload[:voice_id] = options[:voice_id] if options[:voice_id]
  payload[:model_id] = options[:model_id] if options[:model_id]
  payload[:auto_convert] = options[:auto_convert] unless options[:auto_convert].nil?
  payload[:apply_text_normalization] = options[:apply_text_normalization] if options[:apply_text_normalization]
  
  # Add file if provided
  if options[:file] && options[:filename]
    payload[:file] = @client.file_part(options[:file], options[:filename])
  end

  @client.post_multipart(endpoint, payload)
end

#get_settings(project_id) ⇒ Hash Also known as: project_settings

GET /v1/audio-native/:project_id/settings Get player settings for the specific project Documentation: https://elevenlabs.io/docs/api-reference/audio-native/settings

Parameters:

  • project_id (String)

    The ID of the Studio project

Returns:

  • (Hash)

    JSON response containing enabled status, snapshot_id, and settings



89
90
91
92
# File 'lib/elevenlabs_client/endpoints/audio_native.rb', line 89

def get_settings(project_id)
  endpoint = "/v1/audio-native/#{project_id}/settings"
  @client.get(endpoint)
end

#update_content(project_id, **options) ⇒ Hash Also known as: update_project_content

POST /v1/audio-native/:project_id/content Updates content for the specific AudioNative Project Documentation: https://elevenlabs.io/docs/api-reference/audio-native/update

Parameters:

  • project_id (String)

    The ID of the project to be used

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :file (IO, File)

    Text or HTML input file containing article content

  • :filename (String)

    Original filename for the file

  • :auto_convert (Boolean)

    Whether to auto convert project to audio (defaults to false)

  • :auto_publish (Boolean)

    Whether to auto publish after conversion (defaults to false)

Returns:

  • (Hash)

    JSON response containing project_id, converting, publishing status, and html_snippet



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/elevenlabs_client/endpoints/audio_native.rb', line 66

def update_content(project_id, **options)
  endpoint = "/v1/audio-native/#{project_id}/content"
  
  payload = {}
  
  # Add optional parameters if provided
  payload[:auto_convert] = options[:auto_convert] unless options[:auto_convert].nil?
  payload[:auto_publish] = options[:auto_publish] unless options[:auto_publish].nil?
  
  # Add file if provided
  if options[:file] && options[:filename]
    payload[:file] = @client.file_part(options[:file], options[:filename])
  end

  @client.post_multipart(endpoint, payload)
end