elevenlabs_client 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +140 -0
- data/README.md +163 -5
- data/lib/elevenlabs_client/client.rb +80 -3
- data/lib/elevenlabs_client/endpoints/admin/history.rb +106 -0
- data/lib/elevenlabs_client/endpoints/admin/models.rb +27 -0
- data/lib/elevenlabs_client/endpoints/admin/usage.rb +46 -0
- data/lib/elevenlabs_client/endpoints/admin/user.rb +28 -0
- data/lib/elevenlabs_client/endpoints/admin/voice_library.rb +86 -0
- data/lib/elevenlabs_client/endpoints/audio_isolation.rb +71 -0
- data/lib/elevenlabs_client/endpoints/audio_native.rb +103 -0
- data/lib/elevenlabs_client/endpoints/dubs.rb +52 -2
- data/lib/elevenlabs_client/endpoints/forced_alignment.rb +41 -0
- data/lib/elevenlabs_client/endpoints/sound_generation.rb +0 -1
- data/lib/elevenlabs_client/endpoints/speech_to_speech.rb +125 -0
- data/lib/elevenlabs_client/endpoints/speech_to_text.rb +121 -0
- data/lib/elevenlabs_client/endpoints/text_to_dialogue.rb +34 -1
- data/lib/elevenlabs_client/endpoints/text_to_speech.rb +147 -1
- data/lib/elevenlabs_client/endpoints/text_to_voice.rb +13 -1
- data/lib/elevenlabs_client/endpoints/voices.rb +368 -7
- data/lib/elevenlabs_client/endpoints/websocket_text_to_speech.rb +250 -0
- data/lib/elevenlabs_client/version.rb +1 -1
- data/lib/elevenlabs_client.rb +11 -4
- metadata +41 -4
- data/lib/elevenlabs_client/endpoints/models.rb +0 -26
- data/lib/elevenlabs_client/endpoints/text_to_speech_stream.rb +0 -42
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElevenlabsClient
|
4
|
+
module Admin
|
5
|
+
class Usage
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /v1/usage/character-stats
|
11
|
+
# Gets character usage metrics for the current user or workspace
|
12
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/usage/get-character-stats
|
13
|
+
#
|
14
|
+
# @param start_unix [Integer] UTC Unix timestamp for the start of the usage window (in milliseconds)
|
15
|
+
# @param end_unix [Integer] UTC Unix timestamp for the end of the usage window (in milliseconds)
|
16
|
+
# @param include_workspace_metrics [Boolean] Whether to include the statistics of the entire workspace (defaults to false)
|
17
|
+
# @param breakdown_type [String] How to break down the information. Cannot be "user" if include_workspace_metrics is false
|
18
|
+
# @param aggregation_interval [String] How to aggregate usage data over time ("hour", "day", "week", "month", or "cumulative")
|
19
|
+
# @param aggregation_bucket_size [Integer, nil] Aggregation bucket size in seconds. Overrides the aggregation interval
|
20
|
+
# @param metric [String] Which metric to aggregate
|
21
|
+
# @return [Hash] The JSON response containing time axis and usage data
|
22
|
+
def get_character_stats(start_unix:, end_unix:, include_workspace_metrics: nil, breakdown_type: nil, aggregation_interval: nil, aggregation_bucket_size: nil, metric: nil)
|
23
|
+
endpoint = "/v1/usage/character-stats"
|
24
|
+
|
25
|
+
params = {
|
26
|
+
start_unix: start_unix,
|
27
|
+
end_unix: end_unix
|
28
|
+
}
|
29
|
+
|
30
|
+
params[:include_workspace_metrics] = include_workspace_metrics unless include_workspace_metrics.nil?
|
31
|
+
params[:breakdown_type] = breakdown_type if breakdown_type
|
32
|
+
params[:aggregation_interval] = aggregation_interval if aggregation_interval
|
33
|
+
params[:aggregation_bucket_size] = aggregation_bucket_size if aggregation_bucket_size
|
34
|
+
params[:metric] = metric if metric
|
35
|
+
|
36
|
+
@client.get(endpoint, params)
|
37
|
+
end
|
38
|
+
|
39
|
+
alias_method :character_stats, :get_character_stats
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
attr_reader :client
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElevenlabsClient
|
4
|
+
module Admin
|
5
|
+
class User
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /v1/user
|
11
|
+
# Gets information about the user
|
12
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/user/get-user
|
13
|
+
#
|
14
|
+
# @return [Hash] The JSON response containing user information including subscription details
|
15
|
+
def get_user
|
16
|
+
endpoint = "/v1/user"
|
17
|
+
@client.get(endpoint)
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_method :user, :get_user
|
21
|
+
alias_method :info, :get_user
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :client
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElevenlabsClient
|
4
|
+
module Admin
|
5
|
+
class VoiceLibrary
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /v1/shared-voices
|
11
|
+
# Retrieves a list of shared voices
|
12
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/shared-voices/get-shared-voices
|
13
|
+
#
|
14
|
+
# @param page_size [Integer] How many shared voices to return at maximum. Cannot exceed 100, defaults to 30
|
15
|
+
# @param category [String] Voice category used for filtering ("professional", "famous", "high_quality")
|
16
|
+
# @param gender [String, nil] Gender used for filtering
|
17
|
+
# @param age [String, nil] Age used for filtering
|
18
|
+
# @param accent [String, nil] Accent used for filtering
|
19
|
+
# @param language [String, nil] Language used for filtering
|
20
|
+
# @param locale [String, nil] Locale used for filtering
|
21
|
+
# @param search [String, nil] Search term used for filtering
|
22
|
+
# @param use_cases [Array<String>, nil] Use-case used for filtering
|
23
|
+
# @param descriptives [Array<String>, nil] Descriptive terms used for filtering
|
24
|
+
# @param featured [Boolean] Filter featured voices (defaults to false)
|
25
|
+
# @param min_notice_period_days [Integer, nil] Filter voices with a minimum notice period
|
26
|
+
# @param include_custom_rates [Boolean, nil] Include/exclude voices with custom rates
|
27
|
+
# @param include_live_moderated [Boolean, nil] Include/exclude voices that are live moderated
|
28
|
+
# @param reader_app_enabled [Boolean] Filter voices that are enabled for the reader app (defaults to false)
|
29
|
+
# @param owner_id [String, nil] Filter voices by public owner ID
|
30
|
+
# @param sort [String, nil] Sort criteria
|
31
|
+
# @param page [Integer] Page number (defaults to 0)
|
32
|
+
# @return [Hash] The JSON response containing voices array and pagination info
|
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)
|
34
|
+
endpoint = "/v1/shared-voices"
|
35
|
+
|
36
|
+
params = {}
|
37
|
+
params[:page_size] = page_size if page_size
|
38
|
+
params[:category] = category if category
|
39
|
+
params[:gender] = gender if gender
|
40
|
+
params[:age] = age if age
|
41
|
+
params[:accent] = accent if accent
|
42
|
+
params[:language] = language if language
|
43
|
+
params[:locale] = locale if locale
|
44
|
+
params[:search] = search if search
|
45
|
+
params[:use_cases] = use_cases if use_cases
|
46
|
+
params[:descriptives] = descriptives if descriptives
|
47
|
+
params[:featured] = featured unless featured.nil?
|
48
|
+
params[:min_notice_period_days] = min_notice_period_days if min_notice_period_days
|
49
|
+
params[:include_custom_rates] = include_custom_rates unless include_custom_rates.nil?
|
50
|
+
params[:include_live_moderated] = include_live_moderated unless include_live_moderated.nil?
|
51
|
+
params[:reader_app_enabled] = reader_app_enabled unless reader_app_enabled.nil?
|
52
|
+
params[:owner_id] = owner_id if owner_id
|
53
|
+
params[:sort] = sort if sort
|
54
|
+
params[:page] = page if page
|
55
|
+
|
56
|
+
@client.get(endpoint, params)
|
57
|
+
end
|
58
|
+
|
59
|
+
# POST /v1/voices/add/:public_user_id/:voice_id
|
60
|
+
# Add a shared voice to your collection of voices
|
61
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/shared-voices/add-shared-voice
|
62
|
+
#
|
63
|
+
# @param public_user_id [String] Public user ID used to publicly identify ElevenLabs users
|
64
|
+
# @param voice_id [String] ID of the voice to be used
|
65
|
+
# @param new_name [String] The name that identifies this voice
|
66
|
+
# @return [Hash] The JSON response containing the voice_id
|
67
|
+
def add_shared_voice(public_user_id:, voice_id:, new_name:)
|
68
|
+
endpoint = "/v1/voices/add/#{public_user_id}/#{voice_id}"
|
69
|
+
|
70
|
+
body = {
|
71
|
+
new_name: new_name
|
72
|
+
}
|
73
|
+
|
74
|
+
@client.post(endpoint, body)
|
75
|
+
end
|
76
|
+
|
77
|
+
alias_method :shared_voices, :get_shared_voices
|
78
|
+
alias_method :list_shared_voices, :get_shared_voices
|
79
|
+
alias_method :add_voice, :add_shared_voice
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
attr_reader :client
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElevenlabsClient
|
4
|
+
class AudioIsolation
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
# POST /v1/audio-isolation
|
10
|
+
# Removes background noise from audio
|
11
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/audio-isolation
|
12
|
+
#
|
13
|
+
# @param audio_file [IO, File] The audio file from which vocals/speech will be isolated
|
14
|
+
# @param filename [String] Original filename for the audio file
|
15
|
+
# @param options [Hash] Optional parameters
|
16
|
+
# @option options [String] :file_format Format of input audio ('pcm_s16le_16' or 'other', defaults to 'other')
|
17
|
+
# @return [String] Binary audio data with background noise removed
|
18
|
+
def isolate(audio_file, filename, **options)
|
19
|
+
endpoint = "/v1/audio-isolation"
|
20
|
+
|
21
|
+
payload = {
|
22
|
+
audio: @client.file_part(audio_file, filename)
|
23
|
+
}
|
24
|
+
|
25
|
+
# Add optional parameters if provided
|
26
|
+
payload[:file_format] = options[:file_format] if options[:file_format]
|
27
|
+
|
28
|
+
@client.post_multipart(endpoint, payload)
|
29
|
+
end
|
30
|
+
|
31
|
+
# POST /v1/audio-isolation/stream
|
32
|
+
# Removes background noise from audio with streaming response
|
33
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/audio-isolation/stream
|
34
|
+
#
|
35
|
+
# @param audio_file [IO, File] The audio file from which vocals/speech will be isolated
|
36
|
+
# @param filename [String] Original filename for the audio file
|
37
|
+
# @param options [Hash] Optional parameters
|
38
|
+
# @option options [String] :file_format Format of input audio ('pcm_s16le_16' or 'other', defaults to 'other')
|
39
|
+
# @param block [Proc] Block to handle each chunk of streaming audio data
|
40
|
+
# @return [Faraday::Response] Response object for streaming
|
41
|
+
def isolate_stream(audio_file, filename, **options, &block)
|
42
|
+
endpoint = "/v1/audio-isolation/stream"
|
43
|
+
|
44
|
+
payload = {
|
45
|
+
audio: @client.file_part(audio_file, filename)
|
46
|
+
}
|
47
|
+
|
48
|
+
# Add optional parameters if provided
|
49
|
+
payload[:file_format] = options[:file_format] if options[:file_format]
|
50
|
+
|
51
|
+
# Use streaming multipart request
|
52
|
+
response = @client.instance_variable_get(:@conn).post(endpoint) do |req|
|
53
|
+
req.headers["xi-api-key"] = @client.api_key
|
54
|
+
req.body = payload
|
55
|
+
|
56
|
+
# Set up streaming callback if block provided
|
57
|
+
if block_given?
|
58
|
+
req.options.on_data = proc do |chunk, _|
|
59
|
+
block.call(chunk)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
@client.send(:handle_response, response)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
attr_reader :client
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElevenlabsClient
|
4
|
+
class AudioNative
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
# POST /v1/audio-native
|
10
|
+
# Creates Audio Native enabled project, optionally starts conversion and returns project ID and embeddable HTML snippet
|
11
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/audio-native/create
|
12
|
+
#
|
13
|
+
# @param name [String] Project name
|
14
|
+
# @param options [Hash] Optional parameters
|
15
|
+
# @option options [String] :image Image URL used in the player (deprecated)
|
16
|
+
# @option options [String] :author Author used in the player
|
17
|
+
# @option options [String] :title Title used in the player
|
18
|
+
# @option options [Boolean] :small Whether to use small player (deprecated, defaults to false)
|
19
|
+
# @option options [String] :text_color Text color used in the player
|
20
|
+
# @option options [String] :background_color Background color used in the player
|
21
|
+
# @option options [Integer] :sessionization Minutes to persist session (deprecated, defaults to 0)
|
22
|
+
# @option options [String] :voice_id Voice ID used to voice the content
|
23
|
+
# @option options [String] :model_id TTS Model ID used in the player
|
24
|
+
# @option options [IO, File] :file Text or HTML input file containing article content
|
25
|
+
# @option options [String] :filename Original filename for the file
|
26
|
+
# @option options [Boolean] :auto_convert Whether to auto convert project to audio (defaults to false)
|
27
|
+
# @option options [String] :apply_text_normalization Text normalization mode ('auto', 'on', 'off', 'apply_english')
|
28
|
+
# @return [Hash] JSON response containing project_id, converting status, and html_snippet
|
29
|
+
def create(name, **options)
|
30
|
+
endpoint = "/v1/audio-native"
|
31
|
+
|
32
|
+
payload = { name: name }
|
33
|
+
|
34
|
+
# Add optional parameters if provided
|
35
|
+
payload[:image] = options[:image] if options[:image]
|
36
|
+
payload[:author] = options[:author] if options[:author]
|
37
|
+
payload[:title] = options[:title] if options[:title]
|
38
|
+
payload[:small] = options[:small] unless options[:small].nil?
|
39
|
+
payload[:text_color] = options[:text_color] if options[:text_color]
|
40
|
+
payload[:background_color] = options[:background_color] if options[:background_color]
|
41
|
+
payload[:sessionization] = options[:sessionization] if options[:sessionization]
|
42
|
+
payload[:voice_id] = options[:voice_id] if options[:voice_id]
|
43
|
+
payload[:model_id] = options[:model_id] if options[:model_id]
|
44
|
+
payload[:auto_convert] = options[:auto_convert] unless options[:auto_convert].nil?
|
45
|
+
payload[:apply_text_normalization] = options[:apply_text_normalization] if options[:apply_text_normalization]
|
46
|
+
|
47
|
+
# Add file if provided
|
48
|
+
if options[:file] && options[:filename]
|
49
|
+
payload[:file] = @client.file_part(options[:file], options[:filename])
|
50
|
+
end
|
51
|
+
|
52
|
+
@client.post_multipart(endpoint, payload)
|
53
|
+
end
|
54
|
+
|
55
|
+
# POST /v1/audio-native/:project_id/content
|
56
|
+
# Updates content for the specific AudioNative Project
|
57
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/audio-native/update
|
58
|
+
#
|
59
|
+
# @param project_id [String] The ID of the project to be used
|
60
|
+
# @param options [Hash] Optional parameters
|
61
|
+
# @option options [IO, File] :file Text or HTML input file containing article content
|
62
|
+
# @option options [String] :filename Original filename for the file
|
63
|
+
# @option options [Boolean] :auto_convert Whether to auto convert project to audio (defaults to false)
|
64
|
+
# @option options [Boolean] :auto_publish Whether to auto publish after conversion (defaults to false)
|
65
|
+
# @return [Hash] JSON response containing project_id, converting, publishing status, and html_snippet
|
66
|
+
def update_content(project_id, **options)
|
67
|
+
endpoint = "/v1/audio-native/#{project_id}/content"
|
68
|
+
|
69
|
+
payload = {}
|
70
|
+
|
71
|
+
# Add optional parameters if provided
|
72
|
+
payload[:auto_convert] = options[:auto_convert] unless options[:auto_convert].nil?
|
73
|
+
payload[:auto_publish] = options[:auto_publish] unless options[:auto_publish].nil?
|
74
|
+
|
75
|
+
# Add file if provided
|
76
|
+
if options[:file] && options[:filename]
|
77
|
+
payload[:file] = @client.file_part(options[:file], options[:filename])
|
78
|
+
end
|
79
|
+
|
80
|
+
@client.post_multipart(endpoint, payload)
|
81
|
+
end
|
82
|
+
|
83
|
+
# GET /v1/audio-native/:project_id/settings
|
84
|
+
# Get player settings for the specific project
|
85
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/audio-native/settings
|
86
|
+
#
|
87
|
+
# @param project_id [String] The ID of the Studio project
|
88
|
+
# @return [Hash] JSON response containing enabled status, snapshot_id, and settings
|
89
|
+
def get_settings(project_id)
|
90
|
+
endpoint = "/v1/audio-native/#{project_id}/settings"
|
91
|
+
@client.get(endpoint)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Alias methods for convenience
|
95
|
+
alias_method :create_project, :create
|
96
|
+
alias_method :update_project_content, :update_content
|
97
|
+
alias_method :project_settings, :get_settings
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
attr_reader :client
|
102
|
+
end
|
103
|
+
end
|
@@ -8,6 +8,7 @@ module ElevenlabsClient
|
|
8
8
|
|
9
9
|
# POST /v1/dubbing (multipart)
|
10
10
|
# Creates a new dubbing job
|
11
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/create
|
11
12
|
#
|
12
13
|
# @param file_io [IO] The audio/video file to dub
|
13
14
|
# @param filename [String] Original filename
|
@@ -19,8 +20,9 @@ module ElevenlabsClient
|
|
19
20
|
payload = {
|
20
21
|
file: @client.file_part(file_io, filename),
|
21
22
|
mode: "automatic",
|
22
|
-
|
23
|
-
|
23
|
+
name: name,
|
24
|
+
target_lang: target_languages.first,
|
25
|
+
num_speakers: 1
|
24
26
|
}.compact.merge(options)
|
25
27
|
|
26
28
|
@client.post_multipart("/v1/dubbing", payload)
|
@@ -28,6 +30,7 @@ module ElevenlabsClient
|
|
28
30
|
|
29
31
|
# GET /v1/dubbing/{id}
|
30
32
|
# Retrieves dubbing job details
|
33
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/get
|
31
34
|
#
|
32
35
|
# @param dubbing_id [String] The dubbing job ID
|
33
36
|
# @return [Hash] Dubbing job details
|
@@ -37,6 +40,7 @@ module ElevenlabsClient
|
|
37
40
|
|
38
41
|
# GET /v1/dubbing
|
39
42
|
# Lists dubbing jobs
|
43
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing
|
40
44
|
#
|
41
45
|
# @param params [Hash] Query parameters (dubbing_status, page_size, etc.)
|
42
46
|
# @return [Hash] List of dubbing jobs
|
@@ -46,6 +50,7 @@ module ElevenlabsClient
|
|
46
50
|
|
47
51
|
# GET /v1/dubbing/{id}/resources
|
48
52
|
# Retrieves dubbing resources for editing (if dubbing_studio: true was used)
|
53
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/get-resource
|
49
54
|
#
|
50
55
|
# @param dubbing_id [String] The dubbing job ID
|
51
56
|
# @return [Hash] Dubbing resources
|
@@ -55,6 +60,7 @@ module ElevenlabsClient
|
|
55
60
|
|
56
61
|
# DELETE /v1/dubbing/{id}
|
57
62
|
# Deletes a dubbing project
|
63
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/delete
|
58
64
|
#
|
59
65
|
# @param dubbing_id [String] The dubbing job ID
|
60
66
|
# @return [Hash] Response with status
|
@@ -64,6 +70,7 @@ module ElevenlabsClient
|
|
64
70
|
|
65
71
|
# GET /v1/dubbing/resource/{dubbing_id}
|
66
72
|
# Gets dubbing resource with detailed information including segments, speakers, etc.
|
73
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/get-resource
|
67
74
|
#
|
68
75
|
# @param dubbing_id [String] The dubbing job ID
|
69
76
|
# @return [Hash] Detailed dubbing resource information
|
@@ -73,6 +80,7 @@ module ElevenlabsClient
|
|
73
80
|
|
74
81
|
# POST /v1/dubbing/resource/{dubbing_id}/speaker/{speaker_id}/segment
|
75
82
|
# Creates a new segment in dubbing resource
|
83
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/create-segment
|
76
84
|
#
|
77
85
|
# @param dubbing_id [String] The dubbing job ID
|
78
86
|
# @param speaker_id [String] The speaker ID
|
@@ -94,6 +102,7 @@ module ElevenlabsClient
|
|
94
102
|
|
95
103
|
# DELETE /v1/dubbing/resource/{dubbing_id}/segment/{segment_id}
|
96
104
|
# Deletes a single segment from the dubbing
|
105
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/delete-segment
|
97
106
|
#
|
98
107
|
# @param dubbing_id [String] The dubbing job ID
|
99
108
|
# @param segment_id [String] The segment ID
|
@@ -104,6 +113,7 @@ module ElevenlabsClient
|
|
104
113
|
|
105
114
|
# PATCH /v1/dubbing/resource/{dubbing_id}/segment/{segment_id}/{language}
|
106
115
|
# Updates a single segment with new text and/or start/end times
|
116
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/update-segment
|
107
117
|
#
|
108
118
|
# @param dubbing_id [String] The dubbing job ID
|
109
119
|
# @param segment_id [String] The segment ID
|
@@ -124,6 +134,7 @@ module ElevenlabsClient
|
|
124
134
|
|
125
135
|
# POST /v1/dubbing/resource/{dubbing_id}/transcribe
|
126
136
|
# Regenerates transcriptions for specified segments
|
137
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/transcribe-segment
|
127
138
|
#
|
128
139
|
# @param dubbing_id [String] The dubbing job ID
|
129
140
|
# @param segments [Array<String>] List of segment IDs to transcribe
|
@@ -135,6 +146,7 @@ module ElevenlabsClient
|
|
135
146
|
|
136
147
|
# POST /v1/dubbing/resource/{dubbing_id}/translate
|
137
148
|
# Regenerates translations for specified segments/languages
|
149
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/translate-segment
|
138
150
|
#
|
139
151
|
# @param dubbing_id [String] The dubbing job ID
|
140
152
|
# @param segments [Array<String>] List of segment IDs to translate
|
@@ -151,6 +163,7 @@ module ElevenlabsClient
|
|
151
163
|
|
152
164
|
# POST /v1/dubbing/resource/{dubbing_id}/dub
|
153
165
|
# Regenerates dubs for specified segments/languages
|
166
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/dub-segment
|
154
167
|
#
|
155
168
|
# @param dubbing_id [String] The dubbing job ID
|
156
169
|
# @param segments [Array<String>] List of segment IDs to dub
|
@@ -167,6 +180,7 @@ module ElevenlabsClient
|
|
167
180
|
|
168
181
|
# POST /v1/dubbing/resource/{dubbing_id}/render/{language}
|
169
182
|
# Renders the output media for a language
|
183
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/render-project
|
170
184
|
#
|
171
185
|
# @param dubbing_id [String] The dubbing job ID
|
172
186
|
# @param language [String] The language to render
|
@@ -184,6 +198,7 @@ module ElevenlabsClient
|
|
184
198
|
|
185
199
|
# PATCH /v1/dubbing/resource/{dubbing_id}/speaker/{speaker_id}
|
186
200
|
# Updates speaker metadata such as voice
|
201
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/update-speaker
|
187
202
|
#
|
188
203
|
# @param dubbing_id [String] The dubbing job ID
|
189
204
|
# @param speaker_id [String] The speaker ID
|
@@ -201,6 +216,7 @@ module ElevenlabsClient
|
|
201
216
|
|
202
217
|
# GET /v1/dubbing/resource/{dubbing_id}/speaker/{speaker_id}/similar-voices
|
203
218
|
# Gets similar voices for a speaker
|
219
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/resources/get-similar-voices
|
204
220
|
#
|
205
221
|
# @param dubbing_id [String] The dubbing job ID
|
206
222
|
# @param speaker_id [String] The speaker ID
|
@@ -209,6 +225,40 @@ module ElevenlabsClient
|
|
209
225
|
@client.get("/v1/dubbing/resource/#{dubbing_id}/speaker/#{speaker_id}/similar-voices")
|
210
226
|
end
|
211
227
|
|
228
|
+
# GET /v1/dubbing/{dubbing_id}/audio/{language_code}
|
229
|
+
# Returns dub as a streamed MP3 or MP4 file
|
230
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/audio/get
|
231
|
+
#
|
232
|
+
# @param dubbing_id [String] ID of the dubbing project
|
233
|
+
# @param language_code [String] ID of the language
|
234
|
+
# @return [String] Binary audio/video data
|
235
|
+
def get_dubbed_audio(dubbing_id, language_code)
|
236
|
+
endpoint = "/v1/dubbing/#{dubbing_id}/audio/#{language_code}"
|
237
|
+
@client.get(endpoint)
|
238
|
+
end
|
239
|
+
|
240
|
+
# GET /v1/dubbing/{dubbing_id}/transcript/{language_code}
|
241
|
+
# Returns transcript for the dub as an SRT or WEBVTT file
|
242
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/dubbing/transcript/get-transcript-for-dub
|
243
|
+
#
|
244
|
+
# @param dubbing_id [String] ID of the dubbing project
|
245
|
+
# @param language_code [String] ID of the language
|
246
|
+
# @param options [Hash] Optional parameters
|
247
|
+
# @option options [String] :format_type Format to use ("srt" or "webvtt", default: "srt")
|
248
|
+
# @return [String] Transcript in specified format
|
249
|
+
def get_dubbed_transcript(dubbing_id, language_code, **options)
|
250
|
+
endpoint = "/v1/dubbing/#{dubbing_id}/transcript/#{language_code}"
|
251
|
+
|
252
|
+
params = {}
|
253
|
+
params[:format_type] = options[:format_type] if options[:format_type]
|
254
|
+
|
255
|
+
@client.get(endpoint, params)
|
256
|
+
end
|
257
|
+
|
258
|
+
# Alias methods for convenience
|
259
|
+
alias_method :dubbed_audio, :get_dubbed_audio
|
260
|
+
alias_method :dubbed_transcript, :get_dubbed_transcript
|
261
|
+
|
212
262
|
private
|
213
263
|
|
214
264
|
attr_reader :client
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElevenlabsClient
|
4
|
+
class ForcedAlignment
|
5
|
+
def initialize(client)
|
6
|
+
@client = client
|
7
|
+
end
|
8
|
+
|
9
|
+
# POST /v1/forced-alignment
|
10
|
+
# Force align an audio file to text. Get timing information for each character and word
|
11
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/forced-alignment
|
12
|
+
#
|
13
|
+
# @param audio_file [IO, File] The audio file to align (must be less than 1GB)
|
14
|
+
# @param filename [String] Original filename for the audio file
|
15
|
+
# @param text [String] The text to align with the audio
|
16
|
+
# @param options [Hash] Optional parameters
|
17
|
+
# @option options [Boolean] :enabled_spooled_file Stream file in chunks for large files (defaults to false)
|
18
|
+
# @return [Hash] JSON response containing characters, words arrays with timing info, and loss score
|
19
|
+
def create(audio_file, filename, text, **options)
|
20
|
+
endpoint = "/v1/forced-alignment"
|
21
|
+
|
22
|
+
payload = {
|
23
|
+
file: @client.file_part(audio_file, filename),
|
24
|
+
text: text
|
25
|
+
}
|
26
|
+
|
27
|
+
# Add optional parameters if provided
|
28
|
+
payload[:enabled_spooled_file] = options[:enabled_spooled_file] unless options[:enabled_spooled_file].nil?
|
29
|
+
|
30
|
+
@client.post_multipart(endpoint, payload)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Alias methods for convenience
|
34
|
+
alias_method :align, :create
|
35
|
+
alias_method :force_align, :create
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
attr_reader :client
|
40
|
+
end
|
41
|
+
end
|