elevenlabs 0.0.5 → 0.0.6

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: 59c61b4f80cd6efaaa39b93d6ab8ebfdc3a3edce59d2012a984ce8b9f032352d
4
- data.tar.gz: 06c3253d6d21cd59fa5942620de9dee173a3ac926c484dcd17ca378793f6920e
3
+ metadata.gz: 22770e41ca0d3c88d2dc5f83e3e4d9de510610bf1a0adaf9bf675951a647ab30
4
+ data.tar.gz: 8f6ffc3ef844da02c3f45385a730ebbddfe3c711d11e1b983837153c8dbd859a
5
5
  SHA512:
6
- metadata.gz: 5f1cd0d00b602fe88356591d3292dfc6154d722eab9904dea0ec0cd99a5340651be30f44e0470783c1504cabeeed4a0e4dcfab6732c742a650c3c4161129c775
7
- data.tar.gz: b9e3f4821d6e355f811f0d783b36cec64dd103a83713eb13a3ff3ae8c886009294371df5de825ff9287be969b92489b19c90ce426584a81ddb34d8f6e5e97182
6
+ metadata.gz: 1b094e808358b342f7fe8cb08cf993dbafe2bac989bcb1e4655d5de5dd2884ff83626cb098da9b7c06d60a697302d33e848419f80a26fb53f34198f7894390b7
7
+ data.tar.gz: 44ad5334ed45f2628a22be91a0ed307b74f7e8611f6ba71cca0b4ee79f7e510f1f655e45321e47060b413e476ed9ea9913e304a44a789ec388bb7411235d42b4
data/README.md CHANGED
@@ -196,16 +196,20 @@ end
196
196
  ```ruby
197
197
  client.list_voices
198
198
  # => { "voices" => [...] }
199
- ```
200
199
 
201
- 2. **Get Voice Details**
200
+ 2. List Models
201
+
202
+ client.list_models
203
+ # => [...]
204
+
205
+ 3. **Get Voice Details**
202
206
 
203
207
  ```ruby
204
208
  client.get_voice("VOICE_ID")
205
209
  # => { "voice_id" => "...", "name" => "...", ... }
206
210
  ```
207
211
 
208
- 3. **Create a Custom Voice**
212
+ 4. **Create a Custom Voice**
209
213
 
210
214
  ```ruby
211
215
  sample_files = [File.open("sample1.mp3", "rb")]
@@ -213,7 +217,7 @@ client.create_voice("Custom Voice", sample_files, description: "My custom AI voi
213
217
  # => JSON response with new voice details
214
218
  ```
215
219
 
216
- 4. **Check if a Voice is Banned**
220
+ 5. **Check if a Voice is Banned**
217
221
 
218
222
  ```ruby
219
223
  sample_files = [File.open("trump.mp3", "rb")]
@@ -224,28 +228,28 @@ client.banned?(trump)
224
228
  # => true
225
229
  ```
226
230
 
227
- 5. **Edit a Voice**
231
+ 6. **Edit a Voice**
228
232
 
229
233
  ```ruby
230
234
  client.edit_voice("VOICE_ID", name: "Updated Voice Name")
231
235
  # => JSON response with updated details
232
236
  ```
233
237
 
234
- 6. **Delete a Voice**
238
+ 7. **Delete a Voice**
235
239
 
236
240
  ```ruby
237
241
  client.delete_voice("VOICE_ID")
238
242
  # => JSON response acknowledging deletion
239
243
  ```
240
244
 
241
- 7. **Convert Text to Speech**
245
+ 8. **Convert Text to Speech**
242
246
 
243
247
  ```ruby
244
248
  audio_data = client.text_to_speech("VOICE_ID", "Hello world!")
245
249
  File.open("output.mp3", "wb") { |f| f.write(audio_data) }
246
250
  ```
247
251
 
248
- 8. **Stream Text to Speech**
252
+ 9. **Stream Text to Speech**
249
253
 
250
254
  Stream from terminal:
251
255
 
@@ -264,22 +268,48 @@ IO.popen("play -t mp3 -", "wb") do |audio_pipe| # Notice "wb" (write binary)
264
268
  end
265
269
  ```
266
270
 
267
- 9. **Design a Voice**
271
+ 10. **Create a Voice from a Design**
268
272
 
269
- Generate voice previews based on a text description:
273
+ Once you’ve generated a voice design using client.design_voice, you can turn it into a permanent voice in your account by passing its generated_voice_id to client.create_from_generated_voice.
270
274
 
275
+ # Step 1: Design a voice (returns previews + generated_voice_id)
271
276
  ```ruby
272
- response = client.design_voice(
273
- "A deep, resonant male voice with a British accent, suitable for storytelling",
274
- output_format: "mp3_44100_192",
277
+ design_response = client.design_voice(
278
+ "A warm, friendly female voice with a slight Australian accent",
275
279
  model_id: "eleven_multilingual_ttv_v2",
276
- text: "In a land far away, where the mountains meet the sky, a great adventure began. Brave heroes embarked on a quest to find the lost artifact, facing challenges and forging bonds that would last a lifetime. Their journey took them through enchanted forests, across raging rivers, and into the heart of ancient ruins.",
280
+ text: "Welcome to our podcast, where every story is an adventure, taking you on a journey through fascinating worlds, inspiring voices, and unforgettable moments.",
277
281
  auto_generate_text: false
278
282
  )
279
- # Save the first preview to an MP3 file
280
- require "base64"
281
- audio_data = Base64.decode64(response["previews"][0]["audio_base_64"])
282
- File.open("voice_preview.mp3", "wb") { |f| f.write(audio_data) }
283
+
284
+ generated_voice_id = design_response["previews"].first["generated_voice_id"] #three previews are given, but for this example we will use the first to create a voice here
285
+
286
+ # Step 2: Create the permanent voice
287
+ create_response = client.create_from_generated_voice(
288
+ "Friendly Aussie",
289
+ "A warm, friendly Australian-accented voice for podcasts",
290
+ generated_voice_id,
291
+ )
292
+
293
+ voice_id = create_response["voice_id"] # This is the ID you can use for TTS
294
+
295
+ # Step 3: Use the new voice for TTS
296
+ audio_data = client.text_to_speech(voice_id, "This is my new permanent designed voice.")
297
+ File.open("friendly_aussie.mp3", "wb") { |f| f.write(audio_data) }
298
+ ```
299
+ Important notes:
300
+
301
+ Always store the returned voice_id from create_voice_from_design. This is the permanent identifier for TTS.
302
+
303
+ Designed voices cannot be used for TTS until they are created in your account.
304
+
305
+ If the voice is not immediately available for TTS, wait a few seconds or check its status via client.get_voice(voice_id) until it’s "active".
306
+
307
+ 10. Create a multi-speaker dialogue
308
+ ```ruby
309
+ inputs = [{text: "It smells like updog in here", voice_id: "TX3LPaxmHKxFdv7VOQHJ"}, {text: "What's updog?", voice_id: "RILOU7YmBhvwJGDGjNmP"}, {text: "Not much, you?", voice_id: "TX3LPaxmHKxFdv7VOQHJ"}]
310
+
311
+ audio_data = client.text_to_dialogue(inputs)
312
+ File.open("what's updog.mp3", "wb") { |f| f.write(audio_data) }
283
313
  ```
284
314
 
285
315
  ---
@@ -88,6 +88,47 @@ module Elevenlabs
88
88
  handle_error(e)
89
89
  end
90
90
 
91
+ #####################################################
92
+ # Text-to-Dialogue #
93
+ # (POST /v1/text-to-dialogue) #
94
+ #####################################################
95
+
96
+ # Converts a list of text and voice ID pairs into speech (dialogue) and returns audio.
97
+ # Documentation: https://elevenlabs.io/docs/api-reference/text-to-dialogue/convert
98
+ #
99
+ # @param [Array[Objects]] inputs - A list of dialogue inputs, each containing text and a voice ID which will be converted into speech
100
+ # :text => String
101
+ # :voice_id => String
102
+ # @param [String] model_id - optional Identifier of the model to be used
103
+ # @param [Hash] settings - optinal Settings controlling the dialogue generation
104
+ # :stability => double - 0.0 = Creative, 0.5 = Natural, 1.0 = Robust
105
+ # :use_speaker_boost => boolean
106
+ # @param [Integer] seed - optional Best effort to sample deterministically.
107
+ #
108
+ # @return [String] The binary audio data (usually an MP3).
109
+ def text_to_dialogue(inputs, model_id = nil, settings = {}, seed = nil)
110
+ endpoint = "/v1/text-to-dialogue"
111
+ request_body = {}.tap do |r|
112
+ r[:inputs] = inputs
113
+ r[:model_id] = model_id if model_id
114
+ r[:settings] = settings unless settings.empty?
115
+ r[:seed] = seed if seed
116
+ end
117
+
118
+ headers = default_headers
119
+ headers["Accept"] = "audio/mpeg"
120
+
121
+ response = @connection.post(endpoint) do |req|
122
+ req.headers = headers
123
+ req.body = request_body.to_json
124
+ end
125
+
126
+ # Returns raw binary data (often MP3)
127
+ response.body
128
+ rescue Faraday::ClientError => e
129
+ handle_error(e)
130
+ end
131
+
91
132
  #####################################################
92
133
  # Design a Voice #
93
134
  # (POST /v1/text-to-voice/design) #
@@ -194,6 +235,25 @@ module Elevenlabs
194
235
  handle_error(e)
195
236
  end
196
237
 
238
+ #####################################################
239
+ # GET models #
240
+ # (GET /v1/models) #
241
+ #####################################################
242
+
243
+ # Gets a list of available models
244
+ # Documentation: https://elevenlabs.io/docs/api-reference/models/list
245
+ #
246
+ # @return [Hash] The JSON response containing an array of models
247
+ def list_models
248
+ endpoint = "/v1/models"
249
+ response = @connection.get(endpoint) do |req|
250
+ req.headers = default_headers
251
+ end
252
+ JSON.parse(response.body)
253
+ rescue Faraday::ClientError => e
254
+ handle_error(e)
255
+ end
256
+
197
257
  #####################################################
198
258
  # GET a Single Voice #
199
259
  # (GET /v1/voices/{voice_id}) #
data/lib/elevenlabs.rb CHANGED
@@ -5,7 +5,7 @@ require_relative "elevenlabs/client"
5
5
  require_relative "elevenlabs/errors"
6
6
 
7
7
  module Elevenlabs
8
- VERSION = "0.0.5"
8
+ VERSION = "0.0.6"
9
9
 
10
10
  # Optional global configuration
11
11
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elevenlabs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - hackliteracy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-08-09 00:00:00.000000000 Z
11
+ date: 2025-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.1'
41
41
  description: This gem provides a convenient Ruby interface to the ElevenLabs TTS,
42
- Voice Cloning, Voice Design and Streaming endpoints.
42
+ Voice Cloning, Voice Design, Voice dialogues and Streaming endpoints.
43
43
  email:
44
44
  - hackliteracy@gmail.com
45
45
  executables: []