elevenlabs 0.0.6 → 0.0.7
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/README.md +30 -2
- data/lib/elevenlabs/client.rb +104 -0
- data/lib/elevenlabs.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2daafae7b6dbf3724b93ce2022b2fe6ac3703bfbcac12326b75e1a37cd188a39
|
4
|
+
data.tar.gz: ba2227a765efc7538e4aadbe0fcb0917a55c1ba70540a2660b4c75b2545f85da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07d40969dd5fdf8926c2f09c21359df4b5060b1f212797de03ef16c4fcf0dc2b6495c476a9a0741247dccf95dd30fde8d6da7404370b6acc4b61a0ea0ce8f7cd
|
7
|
+
data.tar.gz: 927e01fdc01e4f985466b62e2725f676117f757d3f809d8b4da7ea420e54c0e0a57ab2279cf031dd466451ce8c7a96dd76219da4a7e3d02ada842682a20246f8
|
data/README.md
CHANGED
@@ -14,6 +14,7 @@ This gem provides an easy-to-use interface for:
|
|
14
14
|
- **Converting text to speech** and retrieving the generated audio
|
15
15
|
- **Designing a voice** based on a text description
|
16
16
|
- **Streaming text-to-speech audio**
|
17
|
+
- **Music Generation**
|
17
18
|
|
18
19
|
All requests are handled via [Faraday](https://github.com/lostisland/faraday).
|
19
20
|
|
@@ -304,7 +305,7 @@ Designed voices cannot be used for TTS until they are created in your account.
|
|
304
305
|
|
305
306
|
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
|
|
307
|
-
|
308
|
+
11. Create a multi-speaker dialogue
|
308
309
|
```ruby
|
309
310
|
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
|
|
@@ -312,6 +313,33 @@ audio_data = client.text_to_dialogue(inputs)
|
|
312
313
|
File.open("what's updog.mp3", "wb") { |f| f.write(audio_data) }
|
313
314
|
```
|
314
315
|
|
316
|
+
12. **Generate Music from prompt**
|
317
|
+
```ruby
|
318
|
+
audio = client.compose_music(prompt: "Lo-fi hip hop beat", music_length_ms: 30000)
|
319
|
+
File.binwrite("lofi.mp3", audio)
|
320
|
+
```
|
321
|
+
|
322
|
+
12. **Stream Music Generated from prompt**
|
323
|
+
```ruby
|
324
|
+
File.open("epic_stream.mp3", "wb") do |f|
|
325
|
+
client.compose_music_stream(prompt: "Epic orchestral build", music_length_ms: 60000) do |chunk|
|
326
|
+
f.write(chunk)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
```
|
330
|
+
|
331
|
+
13. **Generate Music with Detailed Metadata (metadata + audio) from prompt**
|
332
|
+
```ruby
|
333
|
+
result = client.compose_music_detailed(prompt: "Jazz piano trio", music_length_ms: 20000)
|
334
|
+
puts result # raw multipart data (needs parsing)
|
335
|
+
```
|
336
|
+
|
337
|
+
14. **Create a music composition plan from prompt**
|
338
|
+
```ruby
|
339
|
+
plan = client.create_music_plan(prompt: "Upbeat pop song with verse and chorus", music_length_ms: 60000)
|
340
|
+
puts plan[:sections]
|
341
|
+
```
|
342
|
+
|
315
343
|
---
|
316
344
|
|
317
345
|
## Error Handling
|
@@ -368,7 +396,7 @@ gem build elevenlabs.gemspec
|
|
368
396
|
Install the gem locally:
|
369
397
|
|
370
398
|
```bash
|
371
|
-
gem install ./elevenlabs-0.0.
|
399
|
+
gem install ./elevenlabs-0.0.7.gem
|
372
400
|
```
|
373
401
|
|
374
402
|
---
|
data/lib/elevenlabs/client.rb
CHANGED
@@ -405,6 +405,110 @@ module Elevenlabs
|
|
405
405
|
voice_id.in?(active_voices)
|
406
406
|
end
|
407
407
|
|
408
|
+
#####################################################
|
409
|
+
# Music API #
|
410
|
+
#####################################################
|
411
|
+
|
412
|
+
# 1. Compose music (basic)
|
413
|
+
# POST /v1/music
|
414
|
+
def compose_music(options = {})
|
415
|
+
endpoint = "/v1/music"
|
416
|
+
request_body = {
|
417
|
+
prompt: options[:prompt],
|
418
|
+
composition_plan: options[:composition_plan],
|
419
|
+
music_length_ms: options[:music_length_ms],
|
420
|
+
model_id: options[:model_id] || "music_v1"
|
421
|
+
}.compact
|
422
|
+
|
423
|
+
headers = default_headers.merge("Accept" => "audio/mpeg")
|
424
|
+
query = {}
|
425
|
+
query[:output_format] = options[:output_format] if options[:output_format]
|
426
|
+
|
427
|
+
response = @connection.post("#{endpoint}?#{URI.encode_www_form(query)}") do |req|
|
428
|
+
req.headers = headers
|
429
|
+
req.body = request_body.to_json
|
430
|
+
end
|
431
|
+
|
432
|
+
response.body # raw binary audio
|
433
|
+
rescue Faraday::ClientError => e
|
434
|
+
handle_error(e)
|
435
|
+
end
|
436
|
+
|
437
|
+
# 2. Stream music
|
438
|
+
# POST /v1/music/stream
|
439
|
+
def compose_music_stream(options = {}, &block)
|
440
|
+
endpoint = "/v1/music/stream"
|
441
|
+
request_body = {
|
442
|
+
prompt: options[:prompt],
|
443
|
+
composition_plan: options[:composition_plan],
|
444
|
+
music_length_ms: options[:music_length_ms],
|
445
|
+
model_id: options[:model_id] || "music_v1"
|
446
|
+
}.compact
|
447
|
+
|
448
|
+
headers = default_headers.merge("Accept" => "audio/mpeg")
|
449
|
+
query = {}
|
450
|
+
query[:output_format] = options[:output_format] if options[:output_format]
|
451
|
+
|
452
|
+
@connection.post("#{endpoint}?#{URI.encode_www_form(query)}") do |req|
|
453
|
+
req.options.on_data = Proc.new do |chunk, _|
|
454
|
+
block.call(chunk) if block
|
455
|
+
end
|
456
|
+
req.headers = headers
|
457
|
+
req.body = request_body.to_json
|
458
|
+
end
|
459
|
+
|
460
|
+
nil # audio streamed via block
|
461
|
+
rescue Faraday::ClientError => e
|
462
|
+
handle_error(e)
|
463
|
+
end
|
464
|
+
|
465
|
+
# 3. Compose detailed music (metadata + audio)
|
466
|
+
# POST /v1/music/detailed
|
467
|
+
def compose_music_detailed(options = {})
|
468
|
+
endpoint = "/v1/music/detailed"
|
469
|
+
request_body = {
|
470
|
+
prompt: options[:prompt],
|
471
|
+
composition_plan: options[:composition_plan],
|
472
|
+
music_length_ms: options[:music_length_ms],
|
473
|
+
model_id: options[:model_id] || "music_v1"
|
474
|
+
}.compact
|
475
|
+
|
476
|
+
headers = default_headers
|
477
|
+
query = {}
|
478
|
+
query[:output_format] = options[:output_format] if options[:output_format]
|
479
|
+
|
480
|
+
response = @connection.post("#{endpoint}?#{URI.encode_www_form(query)}") do |req|
|
481
|
+
req.headers = headers
|
482
|
+
req.body = request_body.to_json
|
483
|
+
end
|
484
|
+
|
485
|
+
response.body # multipart/mixed with JSON + binary audio
|
486
|
+
rescue Faraday::ClientError => e
|
487
|
+
handle_error(e)
|
488
|
+
end
|
489
|
+
|
490
|
+
|
491
|
+
# 4. Create a composition plan
|
492
|
+
# POST /v1/music/plan
|
493
|
+
def create_music_plan(options = {})
|
494
|
+
endpoint = "/v1/music/plan"
|
495
|
+
request_body = {
|
496
|
+
prompt: options[:prompt],
|
497
|
+
music_length_ms: options[:music_length_ms],
|
498
|
+
source_composition_plan: options[:source_composition_plan],
|
499
|
+
model_id: options[:model_id] || "music_v1"
|
500
|
+
}.compact
|
501
|
+
|
502
|
+
response = @connection.post(endpoint) do |req|
|
503
|
+
req.headers = default_headers
|
504
|
+
req.body = request_body.to_json
|
505
|
+
end
|
506
|
+
|
507
|
+
JSON.parse(response.body, symbolize_names: true)
|
508
|
+
rescue Faraday::ClientError => e
|
509
|
+
handle_error(e)
|
510
|
+
end
|
511
|
+
|
408
512
|
private
|
409
513
|
|
410
514
|
# Common headers needed by Elevenlabs
|
data/lib/elevenlabs.rb
CHANGED
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.
|
4
|
+
version: 0.0.7
|
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-
|
11
|
+
date: 2025-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -39,7 +39,8 @@ 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, Voice dialogues
|
42
|
+
Voice Cloning, Voice Design, Voice dialogues, TTS Streaming, Music Generation and
|
43
|
+
Streaming endpoints.
|
43
44
|
email:
|
44
45
|
- hackliteracy@gmail.com
|
45
46
|
executables: []
|