runapi-elevenlabs 0.2.6 → 0.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2229b7034723a96b61a1e969d19787c9765f713c50c6ef6fe14c1b75678d5807
4
- data.tar.gz: 7d95a8156738a7b4c503320c77f6e49f917e88239d5664a85cc79efca740a93e
3
+ metadata.gz: 6ca6826a8bff9028eb05ea1e9bd629b04e9351d7180975e850273fad2bee2785
4
+ data.tar.gz: 9be4ec71de7f881583737af7a5badc4961aa57d36c4c20a6d8c764c2a3634b3e
5
5
  SHA512:
6
- metadata.gz: 664cda394dfc9e26655b26f41c8267fb60f55e1c50b6c9bcbca6d55f3aec28e91a64b3e48bf0fb57348b8a5cc0042596e133787cfe33407777ed4bc7e523069d
7
- data.tar.gz: '0781f940b42c14ed9b87a2992b6345f15679d9da86622e938c312f6f626cb3ff700ff6efac92871f6d6331302bd5ce38ca790e391106510e12779bff5bfe4e84'
6
+ metadata.gz: 7c8f2a8795d4a78ab60d02c9319e3b85e20905b8a5ae890bb65b3f5641dbf862a90728e16c9b6aee688418a9e0b86ecaea52872503a426ef33d56a163971ac65
7
+ data.tar.gz: 552966e452b88bebabe28bcc213bfbbe444b335c27a900823cd5d12d54c0217bbf04166c623d34dbc1e11478dbefd95a046c2061dea9b433fe9e460ee972a212
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Elevenlabs API Ruby SDK for RunAPI
1
+ # ElevenLabs Ruby SDK for RunAPI
2
2
 
3
- The elevenlabs api Ruby SDK is the language-specific package for ElevenLabs on RunAPI. Use this elevenlabs api package for voice, dialogue, transcription, sound effect, and cleanup flows when your application needs JSON request bodies, task status lookup, and consistent RunAPI errors in Ruby.
3
+ The ElevenLabs Ruby SDK is the language-specific package for ElevenLabs on RunAPI. Use this package for voice, dialogue, transcription, sound effect, and audio cleanup workflows when your application needs request bodies, task status lookup, and consistent RunAPI errors in Ruby.
4
4
 
5
- This elevenlabs api README is the Ruby package guide inside the public `elevenlabs-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/elevenlabs; for API reference, use https://runapi.ai/docs#elevenlabs; for SDK docs, use https://runapi.ai/docs#sdk-elevenlabs.
5
+ This README is the Ruby package guide inside the public `elevenlabs-sdk` repository. For the repository overview, start at `../README.md`; for model details, use https://runapi.ai/models/elevenlabs; for API reference, use https://runapi.ai/docs#elevenlabs; for SDK docs, use https://runapi.ai/docs#sdk-elevenlabs.
6
6
 
7
7
  ## Install
8
8
 
@@ -13,20 +13,22 @@ gem install runapi-elevenlabs
13
13
  ## Quick start
14
14
 
15
15
  ```ruby
16
- require "runapi-elevenlabs"
16
+ require "runapi/elevenlabs"
17
17
 
18
18
  client = RunApi::Elevenlabs::Client.new
19
- task = client.speeches.create(
19
+ task = client.text_to_speech.create(
20
20
  # Pass the ElevenLabs JSON request body from https://runapi.ai/docs#elevenlabs.
21
21
  )
22
- status = client.speeches.get(task.id)
22
+ status = client.text_to_speech.get(task.id)
23
23
  ```
24
24
 
25
25
  Use `create` when you want to submit a task and return quickly, `get` when you need the latest task state, and `run` when a script should create and poll until completion. In web request handlers, prefer `create` plus webhook or later `get` polling so a worker is not held open.
26
26
 
27
+ RunAPI-generated file URLs are temporary. Download and store generated images, videos, audio, or other files in your own durable storage within 7 days; do not treat returned URLs as long-term assets.
28
+
27
29
  ## Language notes
28
30
 
29
- Use Ruby keyword arguments and the `RunApi::Elevenlabs` error classes when building audio jobs, Rails workers, or scripts. The available resources include speeches, dialogues, sound effects, transcriptions, and audio isolations. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
31
+ Use Ruby keyword arguments and the `RunApi::Elevenlabs` error classes when building audio jobs, Rails workers, or scripts. The available resources are `text_to_speech`, `text_to_dialogue`, `text_to_sound`, `speech_to_text`, and `isolate_audio`. Keep `RUNAPI_API_KEY` in the environment or your secret manager; never commit API keys or callback secrets.
30
32
 
31
33
  ## Links
32
34
 
@@ -2,14 +2,30 @@
2
2
 
3
3
  module RunApi
4
4
  module Elevenlabs
5
- class Client
6
- attr_reader :text_to_speech, :text_to_dialogue, :text_to_sound, :speech_to_text, :isolate_audio
5
+ # ElevenLabs audio API client for speech synthesis, multi-speaker dialogue,
6
+ # sound effects, transcription, and vocal isolation.
7
+ #
8
+ # @example
9
+ # client = RunApi::Elevenlabs::Client.new(api_key: "sk-...")
10
+ # result = client.text_to_speech.run(
11
+ # model: "text-to-speech-turbo-v2.5",
12
+ # text: "Hello, world!"
13
+ # )
14
+ # puts result.audios.first.url
15
+ class Client < RunApi::Core::Client
16
+ # @return [Resources::TextToSpeech] Single-speaker speech synthesis operations.
17
+ attr_reader :text_to_speech
18
+ # @return [Resources::TextToDialogue] Multi-speaker dialogue synthesis operations.
19
+ attr_reader :text_to_dialogue
20
+ # @return [Resources::TextToSound] Sound effect generation operations.
21
+ attr_reader :text_to_sound
22
+ # @return [Resources::SpeechToText] Audio transcription operations.
23
+ attr_reader :speech_to_text
24
+ # @return [Resources::IsolateAudio] Vocal isolation operations.
25
+ attr_reader :isolate_audio
7
26
 
8
27
  def initialize(api_key: nil, **options)
9
- @api_key = Core::Auth.resolve_api_key(api_key)
10
-
11
- client_options = Core::ClientOptions.new(api_key: @api_key, **options)
12
- http = client_options.http_client || Core::HttpClient.new(client_options)
28
+ super
13
29
 
14
30
  @text_to_speech = Resources::TextToSpeech.new(http)
15
31
  @text_to_dialogue = Resources::TextToDialogue.new(http)
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RunApi
4
+ module Elevenlabs
5
+ CONTRACT = {
6
+ "isolate-audio" => {
7
+ "models" => ["audio-isolation"],
8
+ "fields_by_model" => {
9
+ "audio-isolation" => {
10
+ "source_audio_url" => {
11
+ "required" => true
12
+ }
13
+ }
14
+ }
15
+ },
16
+ "speech-to-text" => {
17
+ "models" => ["speech-to-text"],
18
+ "fields_by_model" => {
19
+ "speech-to-text" => {
20
+ "source_audio_url" => {
21
+ "required" => true
22
+ }
23
+ }
24
+ }
25
+ },
26
+ "text-to-dialogue" => {
27
+ "models" => ["text-to-dialogue-v3"],
28
+ "fields_by_model" => {
29
+ "text-to-dialogue-v3" => {
30
+ "dialogue" => {
31
+ "required" => true
32
+ },
33
+ "stability" => {
34
+ "enum" => [0.0, 0.5, 1.0]
35
+ }
36
+ }
37
+ }
38
+ },
39
+ "text-to-sound" => {
40
+ "models" => ["sound-effect-v2"],
41
+ "fields_by_model" => {
42
+ "sound-effect-v2" => {
43
+ "output_format" => {
44
+ "enum" => ["mp3_22050_32", "mp3_44100_32", "mp3_44100_64", "mp3_44100_96", "mp3_44100_128", "mp3_44100_192", "pcm_8000", "pcm_16000", "pcm_22050", "pcm_24000", "pcm_44100", "pcm_48000", "ulaw_8000", "alaw_8000", "opus_48000_32", "opus_48000_64", "opus_48000_96", "opus_48000_128", "opus_48000_192"]
45
+ },
46
+ "text" => {
47
+ "required" => true
48
+ }
49
+ }
50
+ }
51
+ },
52
+ "text-to-speech" => {
53
+ "models" => ["text-to-speech-multilingual-v2", "text-to-speech-turbo-v2.5"],
54
+ "fields_by_model" => {
55
+ "text-to-speech-multilingual-v2" => {
56
+ "text" => {
57
+ "required" => true
58
+ }
59
+ },
60
+ "text-to-speech-turbo-v2.5" => {
61
+ "text" => {
62
+ "required" => true
63
+ }
64
+ }
65
+ },
66
+ "rules" => [{
67
+ "when" => {
68
+ "model" => "text-to-speech-multilingual-v2"
69
+ },
70
+ "required" => ["voice"]
71
+ }]
72
+ }
73
+ }.freeze
74
+ end
75
+ end
@@ -14,19 +14,19 @@ module RunApi
14
14
  @http = http
15
15
  end
16
16
 
17
- def run(**params)
18
- task = create(**params)
19
- poll_until_complete { get(task.id) }
17
+ def run(options: nil, **params)
18
+ task = create(options: options, **params)
19
+ poll_until_complete { get(task.id, options: options) }
20
20
  end
21
21
 
22
- def create(**params)
22
+ def create(options: nil, **params)
23
23
  params = compact_params(params)
24
24
  raise Core::ValidationError, "source_audio_url is required" unless param(params, :source_audio_url)
25
- request(:post, ENDPOINT, body: params)
25
+ request(:post, ENDPOINT, body: params, options: options)
26
26
  end
27
27
 
28
- def get(id)
29
- request(:get, "#{ENDPOINT}/#{id}")
28
+ def get(id, options: nil)
29
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
30
30
  end
31
31
  end
32
32
  end
@@ -14,19 +14,19 @@ module RunApi
14
14
  @http = http
15
15
  end
16
16
 
17
- def run(**params)
18
- task = create(**params)
19
- poll_until_complete { get(task.id) }
17
+ def run(options: nil, **params)
18
+ task = create(options: options, **params)
19
+ poll_until_complete { get(task.id, options: options) }
20
20
  end
21
21
 
22
- def create(**params)
22
+ def create(options: nil, **params)
23
23
  params = compact_params(params)
24
24
  raise Core::ValidationError, "source_audio_url is required" unless param(params, :source_audio_url)
25
- request(:post, ENDPOINT, body: params)
25
+ request(:post, ENDPOINT, body: params, options: options)
26
26
  end
27
27
 
28
- def get(id)
29
- request(:get, "#{ENDPOINT}/#{id}")
28
+ def get(id, options: nil)
29
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
30
30
  end
31
31
  end
32
32
  end
@@ -14,19 +14,19 @@ module RunApi
14
14
  @http = http
15
15
  end
16
16
 
17
- def run(**params)
18
- task = create(**params)
19
- poll_until_complete { get(task.id) }
17
+ def run(options: nil, **params)
18
+ task = create(options: options, **params)
19
+ poll_until_complete { get(task.id, options: options) }
20
20
  end
21
21
 
22
- def create(**params)
22
+ def create(options: nil, **params)
23
23
  params = compact_params(params)
24
24
  raise Core::ValidationError, "dialogue is required" unless param(params, :dialogue)
25
- request(:post, ENDPOINT, body: params)
25
+ request(:post, ENDPOINT, body: params, options: options)
26
26
  end
27
27
 
28
- def get(id)
29
- request(:get, "#{ENDPOINT}/#{id}")
28
+ def get(id, options: nil)
29
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
30
30
  end
31
31
  end
32
32
  end
@@ -14,22 +14,22 @@ module RunApi
14
14
  @http = http
15
15
  end
16
16
 
17
- def run(**params)
18
- task = create(**params)
19
- poll_until_complete { get(task.id) }
17
+ def run(options: nil, **params)
18
+ task = create(options: options, **params)
19
+ poll_until_complete { get(task.id, options: options) }
20
20
  end
21
21
 
22
- def create(**params)
22
+ def create(options: nil, **params)
23
23
  params = compact_params(params)
24
24
  raise Core::ValidationError, "text is required" unless param(params, :text)
25
25
  if param(params, :output_format) && !Types::TEXT_TO_SOUND_OUTPUT_FORMATS.include?(param(params, :output_format))
26
26
  raise Core::ValidationError, "Invalid output_format"
27
27
  end
28
- request(:post, ENDPOINT, body: params)
28
+ request(:post, ENDPOINT, body: params, options: options)
29
29
  end
30
30
 
31
- def get(id)
32
- request(:get, "#{ENDPOINT}/#{id}")
31
+ def get(id, options: nil)
32
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
33
33
  end
34
34
  end
35
35
  end
@@ -14,29 +14,28 @@ module RunApi
14
14
  @http = http
15
15
  end
16
16
 
17
- def run(**params)
18
- task = create(**params)
19
- poll_until_complete { get(task.id) }
17
+ def run(options: nil, **params)
18
+ task = create(options: options, **params)
19
+ poll_until_complete { get(task.id, options: options) }
20
20
  end
21
21
 
22
- def create(**params)
22
+ def create(options: nil, **params)
23
23
  params = compact_params(params)
24
24
  validate_params!(params)
25
- request(:post, ENDPOINT, body: params)
25
+ request(:post, ENDPOINT, body: params, options: options)
26
26
  end
27
27
 
28
- def get(id)
29
- request(:get, "#{ENDPOINT}/#{id}")
28
+ def get(id, options: nil)
29
+ request(:get, "#{ENDPOINT}/#{id}", options: options)
30
30
  end
31
31
 
32
32
  private
33
33
 
34
34
  def validate_params!(params)
35
- model = param(params, :model)
36
- raise Core::ValidationError, "model is required" unless model
37
- raise Core::ValidationError, "Invalid model: #{model}" unless Types::TEXT_TO_SPEECH_MODELS.include?(model)
38
- raise Core::ValidationError, "text is required" unless param(params, :text)
39
- raise Core::ValidationError, "voice is required for text-to-speech-multilingual-v2" if model == "text-to-speech-multilingual-v2" && !param(params, :voice)
35
+ validate_contract!(CONTRACT["text-to-speech"], params)
36
+ if param(params, :model) == "text-to-speech-multilingual-v2" && !param(params, :voice)
37
+ raise Core::ValidationError, "voice is required for text-to-speech-multilingual-v2"
38
+ end
40
39
  end
41
40
  end
42
41
  end
@@ -3,7 +3,6 @@
3
3
  module RunApi
4
4
  module Elevenlabs
5
5
  module Types
6
- TEXT_TO_SPEECH_MODELS = %w[text-to-speech-turbo-v2.5 text-to-speech-multilingual-v2].freeze
7
6
  DEFAULT_TEXT_TO_SPEECH_VOICE = "EkK5I93UQWFDigLMpZcX"
8
7
  TEXT_TO_SOUND_OUTPUT_FORMATS = %w[
9
8
  mp3_22050_32 mp3_44100_32 mp3_44100_64 mp3_44100_96 mp3_44100_128 mp3_44100_192
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "runapi/core"
4
+ require_relative "elevenlabs/contract_gen"
4
5
  require_relative "elevenlabs/types"
5
6
  require_relative "elevenlabs/resources/text_to_speech"
6
7
  require_relative "elevenlabs/resources/text_to_dialogue"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runapi-elevenlabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - RunAPI
@@ -15,18 +15,18 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: 0.2.5
18
+ version: 0.3.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: 0.2.5
26
- description: The elevenlabs api Ruby SDK is the language-specific package for ElevenLabs
27
- on RunAPI. Use this elevenlabs api package for voice, dialogue, transcription, sound
28
- effect, and cleanup flows when your application needs JSON request bodies, task
29
- status lookup, and consistent RunAPI errors in Ruby.
25
+ version: 0.3.0
26
+ description: The ElevenLabs Ruby SDK is the language-specific package for ElevenLabs
27
+ on RunAPI. Use this package for voice, dialogue, transcription, sound effect, and
28
+ audio cleanup workflows when your application needs request bodies, task status
29
+ lookup, and consistent RunAPI errors in Ruby.
30
30
  email:
31
31
  - contact@runapi.ai
32
32
  executables: []
@@ -39,6 +39,7 @@ files:
39
39
  - lib/runapi-elevenlabs.rb
40
40
  - lib/runapi/elevenlabs.rb
41
41
  - lib/runapi/elevenlabs/client.rb
42
+ - lib/runapi/elevenlabs/contract_gen.rb
42
43
  - lib/runapi/elevenlabs/resources/isolate_audio.rb
43
44
  - lib/runapi/elevenlabs/resources/speech_to_text.rb
44
45
  - lib/runapi/elevenlabs/resources/text_to_dialogue.rb
@@ -49,9 +50,11 @@ homepage: https://runapi.ai/models/elevenlabs
49
50
  licenses:
50
51
  - Apache-2.0
51
52
  metadata:
53
+ runapi_slug: elevenlabs
52
54
  homepage_uri: https://runapi.ai/models/elevenlabs
53
55
  documentation_uri: https://github.com/runapi-ai/elevenlabs-sdk/blob/main/ruby/README.md
54
56
  source_code_uri: https://github.com/runapi-ai/elevenlabs-sdk
57
+ bug_tracker_uri: https://github.com/runapi-ai/elevenlabs-sdk/issues
55
58
  changelog_uri: https://github.com/runapi-ai/elevenlabs-sdk/blob/main/CHANGELOG.md
56
59
  rdoc_options: []
57
60
  require_paths:
@@ -67,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
70
  - !ruby/object:Gem::Version
68
71
  version: '0'
69
72
  requirements: []
70
- rubygems_version: 4.0.10
73
+ rubygems_version: 4.0.17
71
74
  specification_version: 4
72
- summary: Elevenlabs API Ruby SDK for RunAPI
75
+ summary: ElevenLabs Ruby SDK for RunAPI
73
76
  test_files: []