elevenlabs_client 0.5.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 +108 -0
- data/README.md +85 -4
- data/lib/elevenlabs_client/client.rb +35 -6
- 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/sound_generation.rb +0 -1
- data/lib/elevenlabs_client/endpoints/speech_to_text.rb +13 -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 +23 -24
- data/lib/elevenlabs_client/version.rb +1 -1
- data/lib/elevenlabs_client.rb +5 -5
- metadata +21 -7
- data/lib/elevenlabs_client/endpoints/models.rb +0 -26
- data/lib/elevenlabs_client/endpoints/text_to_dialogue_stream.rb +0 -50
- data/lib/elevenlabs_client/endpoints/text_to_speech_stream.rb +0 -43
- data/lib/elevenlabs_client/endpoints/text_to_speech_stream_with_timestamps.rb +0 -75
- data/lib/elevenlabs_client/endpoints/text_to_speech_with_timestamps.rb +0 -73
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ac0295ca5dadf36f14152af7d6c2f4fa39dd7a2c8b59837551fc3bd8839d419
|
4
|
+
data.tar.gz: dabd65a40bb17aa262f2251f125d8edadaccde957b4fe9084b91384f59b54ee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ceb86051b205481e427aec671deeb55fbeaff5f68bf99fe7257e34ce926cd83b7ec7644d5daf4854dc67ff6ece921c23ba99e6301063beb1116084f6820de4be
|
7
|
+
data.tar.gz: e6ab2b8907aa8b02e4ba222a407d5aa3c67e0e86b303421b073f0ed7744a9a9712510d88f75247cd534ddc1c67ccfb8ed5c0d411cee9cd3632288cf35d544036
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,114 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [0.6.0] - 2024-09-15
|
11
|
+
|
12
|
+
### Added
|
13
|
+
- **๐ข Admin API Suite** - Complete administrative functionality for account management
|
14
|
+
- **User Management** (`client.user.*`) - Access comprehensive user account information, subscription details, and feature availability
|
15
|
+
- **Usage Analytics** (`client.usage.*`) - Monitor character usage with detailed analytics, breakdowns by voice/model/source, and trend analysis
|
16
|
+
- **Voice Library** (`client.voice_library.*`) - Browse and manage community shared voices with advanced filtering and search capabilities
|
17
|
+
- All admin endpoints include comprehensive error handling and response validation
|
18
|
+
|
19
|
+
### Enhanced
|
20
|
+
- **๐ Documentation Expansion** - Comprehensive documentation for all admin functionality
|
21
|
+
- Added `docs/admin/USER.md` - User account and subscription management guide (589 lines)
|
22
|
+
- Added `docs/admin/USAGE.md` - Usage analytics and monitoring guide (604 lines)
|
23
|
+
- Added `docs/admin/VOICE_LIBRARY.md` - Voice library browsing and management guide (883 lines)
|
24
|
+
- Added `docs/admin/README.md` - Admin API overview and quick start guide (472 lines)
|
25
|
+
- Updated main README.md with admin endpoint documentation and examples
|
26
|
+
- Total: 3,512 lines of new admin documentation
|
27
|
+
|
28
|
+
- **๐ฏ Example Controllers** - Production-ready Rails integration examples
|
29
|
+
- Added `examples/admin/user_controller.rb` - User dashboard with health monitoring (767 lines)
|
30
|
+
- Added `examples/admin/usage_controller.rb` - Usage analytics dashboard with real-time monitoring (584 lines)
|
31
|
+
- Added `examples/admin/voice_library_controller.rb` - Voice library browser with curation tools (844 lines)
|
32
|
+
- Added `examples/admin/models_controller.rb` - Model comparison and selection guide (983 lines)
|
33
|
+
- All controllers include comprehensive error handling, JSON API support, and export functionality
|
34
|
+
|
35
|
+
### Improved
|
36
|
+
- **๐งช Test Coverage** - Comprehensive testing for all admin functionality
|
37
|
+
- Added 88 endpoint tests covering all admin API methods and error scenarios
|
38
|
+
- Added 77 integration tests covering real-world usage patterns and workflows
|
39
|
+
- All tests include proper error handling validation and response structure verification
|
40
|
+
- Total: 165 new tests with 100% pass rate
|
41
|
+
|
42
|
+
- **๐ง Client Integration** - Seamless integration of admin endpoints
|
43
|
+
- Updated `Client` class to expose all admin endpoints (`usage`, `user`, `voice_library`)
|
44
|
+
- Enhanced error handling for admin-specific scenarios
|
45
|
+
- Consistent API patterns across all admin endpoints
|
46
|
+
- Proper namespacing under `ElevenlabsClient::Admin` module
|
47
|
+
|
48
|
+
### Technical Improvements
|
49
|
+
- **๐ Advanced Analytics** - Sophisticated usage monitoring and insights
|
50
|
+
- Character usage breakdowns by voice, model, user, and source
|
51
|
+
- Time-based aggregation (hour, day, week, month, cumulative)
|
52
|
+
- Trend analysis and forecasting capabilities
|
53
|
+
- Cost estimation and optimization recommendations
|
54
|
+
|
55
|
+
- **๐ค Voice Discovery** - Powerful voice library management
|
56
|
+
- Advanced filtering by category, gender, age, accent, language, and use case
|
57
|
+
- Voice recommendation engine based on requirements
|
58
|
+
- Bulk voice addition and collection curation tools
|
59
|
+
- Voice analytics and popularity tracking
|
60
|
+
|
61
|
+
- **๐ค Account Management** - Comprehensive user account oversight
|
62
|
+
- Real-time subscription monitoring and health checks
|
63
|
+
- Usage limit tracking with projections and alerts
|
64
|
+
- Feature availability matrix and upgrade recommendations
|
65
|
+
- Security and moderation status monitoring
|
66
|
+
|
67
|
+
### Changed
|
68
|
+
- **๐ Code Organization** - Moved TextToDialogue class to its own file
|
69
|
+
- Extracted `TextToDialogue` class from `text_to_speech.rb` to `text_to_dialogue.rb`
|
70
|
+
- Improved code organization and modularity
|
71
|
+
- All tests and functionality remain unchanged
|
72
|
+
- Added Speech-to-Text delete transcript endpoint (`delete_transcript`)
|
73
|
+
|
74
|
+
## [0.5.1] - 2024-09-15
|
75
|
+
|
76
|
+
### Removed
|
77
|
+
- **๐งน Dependency Optimization** - Removed unnecessary development dependencies
|
78
|
+
- Removed `rubocop` and `rubocop-rspec` dependencies
|
79
|
+
- Removed `brakeman` dependency (not suitable for gem libraries)
|
80
|
+
- Removed `.rubocop.yml` and `.brakeman.yml` configuration files
|
81
|
+
- Reduced bundle size from 49 to 31 gems (37% reduction)
|
82
|
+
|
83
|
+
### Changed
|
84
|
+
- **โก CI/CD Optimization** - Simplified and streamlined continuous integration
|
85
|
+
- Removed linting job from GitHub Actions workflow
|
86
|
+
- Focused CI pipeline on essential checks: tests, security, and build
|
87
|
+
- Updated CI to use only `bundler-audit` for dependency vulnerability scanning
|
88
|
+
- Faster CI builds with fewer dependencies and simpler workflow
|
89
|
+
|
90
|
+
### Updated
|
91
|
+
- **๐ Documentation Cleanup** - Updated documentation to reflect simplified toolchain
|
92
|
+
- Removed RuboCop references from README.md
|
93
|
+
- Updated CI/CD documentation section
|
94
|
+
- Simplified development workflow documentation
|
95
|
+
- Updated Rake task descriptions and help text
|
96
|
+
- **๐ง Development Tools** - Streamlined development workflow
|
97
|
+
- Removed lint-related Rake tasks (`dev:lint`, `dev:lint_fix`, `dev:brakeman`)
|
98
|
+
- Simplified `release:prepare` task to focus on tests and security
|
99
|
+
- Updated help documentation for available Rake tasks
|
100
|
+
|
101
|
+
### Technical Improvements
|
102
|
+
- **๐ฆ Leaner Dependencies** - More focused dependency management
|
103
|
+
- Kept only essential development tools: RSpec, WebMock, bundler-audit
|
104
|
+
- Maintained security scanning through bundler-audit
|
105
|
+
- Improved bundle install speed and reduced maintenance overhead
|
106
|
+
- **๐ Performance** - Faster development and CI workflows
|
107
|
+
- Reduced Docker image sizes for CI/CD
|
108
|
+
- Faster bundle installations
|
109
|
+
- Simplified toolchain reduces cognitive overhead
|
110
|
+
|
111
|
+
### Notes
|
112
|
+
- This release focuses on optimizing the development experience and CI/CD pipeline
|
113
|
+
- Security scanning is maintained through bundler-audit, which is more appropriate for gem libraries
|
114
|
+
- The simplified toolchain reduces maintenance overhead while maintaining code quality through comprehensive testing
|
115
|
+
|
8
116
|
## [0.5.0] - 2025-09-14
|
9
117
|
|
10
118
|
### Added
|
data/README.md
CHANGED
@@ -18,7 +18,12 @@ A comprehensive Ruby client library for the ElevenLabs API, supporting voice syn
|
|
18
18
|
๐ **Audio Isolation** - Remove background noise from audio files
|
19
19
|
๐ฑ **Audio Native** - Create embeddable audio players for websites
|
20
20
|
โฑ๏ธ **Forced Alignment** - Get precise timing information for audio transcripts
|
21
|
-
|
21
|
+
๐ **Admin APIs** - Complete administrative functionality:
|
22
|
+
- **History** - Manage and analyze your generated audio history
|
23
|
+
- **Usage** - Monitor character usage and analytics
|
24
|
+
- **User** - Access account information and subscription details
|
25
|
+
- **Voice Library** - Browse and manage community shared voices
|
26
|
+
- **Models** - List available models and their capabilities
|
22
27
|
๐ก **Streaming** - Real-time audio streaming
|
23
28
|
โ๏ธ **Configurable** - Flexible configuration options
|
24
29
|
๐งช **Well-tested** - Comprehensive test coverage
|
@@ -118,6 +123,11 @@ audio_data = client.sound_generation.generate("Ocean waves crashing on rocks")
|
|
118
123
|
design_result = client.text_to_voice.design("Warm, professional female voice")
|
119
124
|
generated_voice_id = design_result["previews"].first["generated_voice_id"]
|
120
125
|
|
126
|
+
# Stream the voice preview
|
127
|
+
client.text_to_voice.stream_preview(generated_voice_id) do |chunk|
|
128
|
+
puts "Received preview chunk: #{chunk.bytesize} bytes"
|
129
|
+
end
|
130
|
+
|
121
131
|
voice_result = client.text_to_voice.create(
|
122
132
|
"Professional Voice",
|
123
133
|
"Warm, professional female voice",
|
@@ -139,6 +149,27 @@ File.open("sample1.mp3", "rb") do |sample|
|
|
139
149
|
puts "Created voice: #{voice['voice_id']}"
|
140
150
|
end
|
141
151
|
|
152
|
+
# Admin APIs - Account Management
|
153
|
+
user_info = client.user.get_user
|
154
|
+
puts "Account: #{user_info['subscription']['tier']} (#{user_info['subscription']['status']})"
|
155
|
+
puts "Usage: #{user_info['subscription']['character_count']} / #{user_info['subscription']['character_limit']}"
|
156
|
+
|
157
|
+
# Usage Analytics
|
158
|
+
usage_stats = client.usage.get_character_stats(
|
159
|
+
start_unix: (Time.now - 7.days).to_i * 1000,
|
160
|
+
end_unix: Time.now.to_i * 1000,
|
161
|
+
breakdown_type: "voice"
|
162
|
+
)
|
163
|
+
puts "7-day usage: #{usage_stats['usage']['All'].sum} characters"
|
164
|
+
|
165
|
+
# History Management
|
166
|
+
history = client.history.list(page_size: 10)
|
167
|
+
puts "Recent history: #{history['history'].length} items"
|
168
|
+
|
169
|
+
# Voice Library
|
170
|
+
voices = client.voice_library.get_shared_voices(category: "professional", page_size: 5)
|
171
|
+
puts "Professional voices available: #{voices['voices'].length}"
|
172
|
+
|
142
173
|
# Music Generation
|
143
174
|
music_data = client.music.compose(
|
144
175
|
prompt: "Upbeat electronic dance track with synthesizers",
|
@@ -167,6 +198,12 @@ File.open("audio.mp3", "rb") do |audio_file|
|
|
167
198
|
timestamps_granularity: "word"
|
168
199
|
)
|
169
200
|
puts "Transcribed: #{transcription['text']}"
|
201
|
+
|
202
|
+
# Get the transcript later
|
203
|
+
transcript = client.speech_to_text.get_transcript(transcription['transcription_id'])
|
204
|
+
|
205
|
+
# Delete when no longer needed
|
206
|
+
client.speech_to_text.delete_transcript(transcription['transcription_id'])
|
170
207
|
end
|
171
208
|
|
172
209
|
# Audio Isolation (Background Noise Removal)
|
@@ -224,7 +261,12 @@ end
|
|
224
261
|
- **[Audio Isolation API](docs/AUDIO_ISOLATION.md)** - Remove background noise from audio
|
225
262
|
- **[Audio Native API](docs/AUDIO_NATIVE.md)** - Create embeddable audio players
|
226
263
|
- **[Forced Alignment API](docs/FORCED_ALIGNMENT.md)** - Get precise timing information
|
227
|
-
- **[
|
264
|
+
- **[Admin APIs](docs/admin/README.md)** - Complete administrative functionality:
|
265
|
+
- **[User Management](docs/admin/USER.md)** - Account information and subscription details
|
266
|
+
- **[Usage Analytics](docs/admin/USAGE.md)** - Character usage monitoring and analytics
|
267
|
+
- **[History Management](docs/admin/HISTORY.md)** - Generated audio history management
|
268
|
+
- **[Voice Library](docs/admin/VOICE_LIBRARY.md)** - Community voice browsing and management
|
269
|
+
- **[Models API](docs/admin/MODELS.md)** - List available models and capabilities
|
228
270
|
|
229
271
|
### Available Endpoints
|
230
272
|
|
@@ -243,7 +285,11 @@ end
|
|
243
285
|
| `client.audio_isolation.*` | Background noise removal | [AUDIO_ISOLATION.md](docs/AUDIO_ISOLATION.md) |
|
244
286
|
| `client.audio_native.*` | Embeddable audio players | [AUDIO_NATIVE.md](docs/AUDIO_NATIVE.md) |
|
245
287
|
| `client.forced_alignment.*` | Audio-text timing alignment | [FORCED_ALIGNMENT.md](docs/FORCED_ALIGNMENT.md) |
|
246
|
-
| `client.
|
288
|
+
| `client.user.*` | User account and subscription information | [USER.md](docs/admin/USER.md) |
|
289
|
+
| `client.usage.*` | Character usage analytics and monitoring | [USAGE.md](docs/admin/USAGE.md) |
|
290
|
+
| `client.history.*` | Generated audio history management | [HISTORY.md](docs/admin/HISTORY.md) |
|
291
|
+
| `client.voice_library.*` | Community voice browsing and management | [VOICE_LIBRARY.md](docs/admin/VOICE_LIBRARY.md) |
|
292
|
+
| `client.models.*` | Model information and capabilities | [MODELS.md](docs/admin/MODELS.md) |
|
247
293
|
|
248
294
|
## Configuration Options
|
249
295
|
|
@@ -312,6 +358,12 @@ The gem is designed to work seamlessly with Rails applications. See the [example
|
|
312
358
|
- [AudioIsolationController](examples/audio_isolation_controller.rb) - Background noise removal and audio cleanup
|
313
359
|
- [AudioNativeController](examples/audio_native_controller.rb) - Embeddable audio players for websites
|
314
360
|
- [ForcedAlignmentController](examples/forced_alignment_controller.rb) - Audio-text timing alignment and subtitle generation
|
361
|
+
- **Admin Controllers** - Complete administrative functionality:
|
362
|
+
- [Admin::HistoryController](examples/admin/history_controller.rb) - Generated audio history management and analytics
|
363
|
+
- [Admin::UsageController](examples/admin/usage_controller.rb) - Character usage monitoring and analytics
|
364
|
+
- [Admin::UserController](examples/admin/user_controller.rb) - User account and subscription management
|
365
|
+
- [Admin::VoiceLibraryController](examples/admin/voice_library_controller.rb) - Community voice browsing and management
|
366
|
+
- [Admin::ModelsController](examples/admin/models_controller.rb) - Model information and selection guidance
|
315
367
|
|
316
368
|
## Development
|
317
369
|
|
@@ -322,6 +374,34 @@ bin/setup # Install dependencies
|
|
322
374
|
bundle exec rspec # Run tests
|
323
375
|
```
|
324
376
|
|
377
|
+
### Available Rake Tasks
|
378
|
+
|
379
|
+
```bash
|
380
|
+
# Testing
|
381
|
+
rake spec # Run all tests (default)
|
382
|
+
rake test:unit # Run unit tests only
|
383
|
+
rake test:integration # Run integration tests only
|
384
|
+
|
385
|
+
# Security
|
386
|
+
rake dev:security # Run security checks
|
387
|
+
rake dev:audit # Run bundler-audit
|
388
|
+
|
389
|
+
# Development
|
390
|
+
rake dev:test # Run all tests
|
391
|
+
rake dev:coverage # Run tests with coverage
|
392
|
+
rake release:prepare # Run full CI suite locally
|
393
|
+
```
|
394
|
+
|
395
|
+
### Continuous Integration
|
396
|
+
|
397
|
+
This gem uses GitHub Actions for CI/CD with the following checks:
|
398
|
+
|
399
|
+
- **Tests**: Runs on Ruby 3.0, 3.1, 3.2, and 3.3
|
400
|
+
- **Security**: bundler-audit for dependency vulnerability scanning
|
401
|
+
- **Build**: Verifies gem can be built and installed
|
402
|
+
|
403
|
+
All checks must pass before merging pull requests.
|
404
|
+
|
325
405
|
To install this gem onto your local machine:
|
326
406
|
|
327
407
|
```bash
|
@@ -332,7 +412,8 @@ To release a new version:
|
|
332
412
|
|
333
413
|
1. Update the version number in `version.rb`
|
334
414
|
2. Update `CHANGELOG.md`
|
335
|
-
3. Run `bundle exec rake release`
|
415
|
+
3. Run `bundle exec rake release:prepare` to verify tests and security checks pass
|
416
|
+
4. Run `bundle exec rake release`
|
336
417
|
|
337
418
|
## Testing
|
338
419
|
|
@@ -8,7 +8,7 @@ module ElevenlabsClient
|
|
8
8
|
class Client
|
9
9
|
DEFAULT_BASE_URL = "https://api.elevenlabs.io"
|
10
10
|
|
11
|
-
attr_reader :base_url, :api_key, :dubs, :text_to_speech, :
|
11
|
+
attr_reader :base_url, :api_key, :dubs, :text_to_speech, :text_to_dialogue, :sound_generation, :text_to_voice, :models, :voices, :music, :audio_isolation, :audio_native, :forced_alignment, :speech_to_speech, :speech_to_text, :websocket_text_to_speech, :history, :usage, :user, :voice_library
|
12
12
|
|
13
13
|
def initialize(api_key: nil, base_url: nil, api_key_env: "ELEVENLABS_API_KEY", base_url_env: "ELEVENLABS_BASE_URL")
|
14
14
|
@api_key = api_key || fetch_api_key(api_key_env)
|
@@ -16,14 +16,14 @@ module ElevenlabsClient
|
|
16
16
|
@conn = build_connection
|
17
17
|
@dubs = Dubs.new(self)
|
18
18
|
@text_to_speech = TextToSpeech.new(self)
|
19
|
-
@text_to_speech_stream = TextToSpeechStream.new(self)
|
20
|
-
@text_to_speech_with_timestamps = TextToSpeechWithTimestamps.new(self)
|
21
|
-
@text_to_speech_stream_with_timestamps = TextToSpeechStreamWithTimestamps.new(self)
|
22
19
|
@text_to_dialogue = TextToDialogue.new(self)
|
23
|
-
@text_to_dialogue_stream = TextToDialogueStream.new(self)
|
24
20
|
@sound_generation = SoundGeneration.new(self)
|
25
21
|
@text_to_voice = TextToVoice.new(self)
|
26
|
-
@models = Models.new(self)
|
22
|
+
@models = Admin::Models.new(self)
|
23
|
+
@history = Admin::History.new(self)
|
24
|
+
@usage = Admin::Usage.new(self)
|
25
|
+
@user = Admin::User.new(self)
|
26
|
+
@voice_library = Admin::VoiceLibrary.new(self)
|
27
27
|
@voices = Voices.new(self)
|
28
28
|
@music = Endpoints::Music.new(self)
|
29
29
|
@audio_isolation = AudioIsolation.new(self)
|
@@ -98,6 +98,17 @@ module ElevenlabsClient
|
|
98
98
|
handle_response(response)
|
99
99
|
end
|
100
100
|
|
101
|
+
# Makes an authenticated GET request expecting binary response
|
102
|
+
# @param path [String] API endpoint path
|
103
|
+
# @return [String] Binary response body
|
104
|
+
def get_binary(path)
|
105
|
+
response = @conn.get(path) do |req|
|
106
|
+
req.headers["xi-api-key"] = api_key
|
107
|
+
end
|
108
|
+
|
109
|
+
handle_response(response)
|
110
|
+
end
|
111
|
+
|
101
112
|
# Makes an authenticated POST request expecting binary response
|
102
113
|
# @param path [String] API endpoint path
|
103
114
|
# @param body [Hash, nil] Request body
|
@@ -154,6 +165,24 @@ module ElevenlabsClient
|
|
154
165
|
handle_response(response)
|
155
166
|
end
|
156
167
|
|
168
|
+
# Makes an authenticated GET request with streaming response
|
169
|
+
# @param path [String] API endpoint path
|
170
|
+
# @param block [Proc] Block to handle each chunk
|
171
|
+
# @return [Faraday::Response] Response object
|
172
|
+
def get_streaming(path, &block)
|
173
|
+
response = @conn.get(path) do |req|
|
174
|
+
req.headers["xi-api-key"] = api_key
|
175
|
+
req.headers["Accept"] = "audio/mpeg"
|
176
|
+
|
177
|
+
# Set up streaming callback
|
178
|
+
req.options.on_data = proc do |chunk, _|
|
179
|
+
block.call(chunk) if block_given?
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
handle_response(response)
|
184
|
+
end
|
185
|
+
|
157
186
|
# Makes an authenticated POST request with streaming response for timestamp data
|
158
187
|
# @param path [String] API endpoint path
|
159
188
|
# @param body [Hash, nil] Request body
|
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module ElevenlabsClient
|
6
|
+
module Admin
|
7
|
+
class History
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
# GET /v1/history
|
13
|
+
# Returns a list of your generated audio
|
14
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/history/get-generated-items
|
15
|
+
#
|
16
|
+
# @param options [Hash] Optional parameters
|
17
|
+
# @option options [Integer] :page_size How many history items to return at maximum (max 1000, default 100)
|
18
|
+
# @option options [String] :start_after_history_item_id After which ID to start fetching (for pagination)
|
19
|
+
# @option options [String] :voice_id ID of the voice to filter for
|
20
|
+
# @option options [String] :search Search term for filtering history items
|
21
|
+
# @option options [String] :source Source of the generated history item ("TTS" or "STS")
|
22
|
+
# @return [Hash] Response containing history items, pagination info
|
23
|
+
def list(**options)
|
24
|
+
endpoint = "/v1/history"
|
25
|
+
|
26
|
+
# Build query parameters
|
27
|
+
query_params = {}
|
28
|
+
query_params[:page_size] = options[:page_size] if options[:page_size]
|
29
|
+
query_params[:start_after_history_item_id] = options[:start_after_history_item_id] if options[:start_after_history_item_id]
|
30
|
+
query_params[:voice_id] = options[:voice_id] if options[:voice_id]
|
31
|
+
query_params[:search] = options[:search] if options[:search]
|
32
|
+
query_params[:source] = options[:source] if options[:source]
|
33
|
+
|
34
|
+
# Add query parameters to endpoint if any exist
|
35
|
+
if query_params.any?
|
36
|
+
query_string = query_params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join("&")
|
37
|
+
endpoint += "?#{query_string}"
|
38
|
+
end
|
39
|
+
|
40
|
+
@client.get(endpoint)
|
41
|
+
end
|
42
|
+
|
43
|
+
# GET /v1/history/:history_item_id
|
44
|
+
# Retrieves a history item by ID
|
45
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/history/get-history-item
|
46
|
+
#
|
47
|
+
# @param history_item_id [String] ID of the history item
|
48
|
+
# @return [Hash] The history item data
|
49
|
+
def get(history_item_id)
|
50
|
+
endpoint = "/v1/history/#{history_item_id}"
|
51
|
+
@client.get(endpoint)
|
52
|
+
end
|
53
|
+
|
54
|
+
# DELETE /v1/history/:history_item_id
|
55
|
+
# Delete a history item by its ID
|
56
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/history/delete-history-item
|
57
|
+
#
|
58
|
+
# @param history_item_id [String] ID of the history item to delete
|
59
|
+
# @return [Hash] Status response
|
60
|
+
def delete(history_item_id)
|
61
|
+
endpoint = "/v1/history/#{history_item_id}"
|
62
|
+
@client.delete(endpoint)
|
63
|
+
end
|
64
|
+
|
65
|
+
# GET /v1/history/:history_item_id/audio
|
66
|
+
# Returns the audio of a history item
|
67
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/history/get-audio-from-history-item
|
68
|
+
#
|
69
|
+
# @param history_item_id [String] ID of the history item
|
70
|
+
# @return [String] The binary audio data
|
71
|
+
def get_audio(history_item_id)
|
72
|
+
endpoint = "/v1/history/#{history_item_id}/audio"
|
73
|
+
@client.get_binary(endpoint)
|
74
|
+
end
|
75
|
+
|
76
|
+
# POST /v1/history/download
|
77
|
+
# Download one or more history items
|
78
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/history/download-history-items
|
79
|
+
#
|
80
|
+
# @param history_item_ids [Array<String>] List of history item IDs to download
|
81
|
+
# @param options [Hash] Optional parameters
|
82
|
+
# @option options [String] :output_format Output format ("wav" or "default")
|
83
|
+
# @return [String] The binary audio data (single file) or zip file (multiple files)
|
84
|
+
def download(history_item_ids, **options)
|
85
|
+
endpoint = "/v1/history/download"
|
86
|
+
request_body = { history_item_ids: history_item_ids }
|
87
|
+
|
88
|
+
# Add optional parameters
|
89
|
+
request_body[:output_format] = options[:output_format] if options[:output_format]
|
90
|
+
|
91
|
+
@client.post_binary(endpoint, request_body)
|
92
|
+
end
|
93
|
+
|
94
|
+
# Alias methods for convenience
|
95
|
+
alias_method :get_history_item, :get
|
96
|
+
alias_method :get_generated_items, :list
|
97
|
+
alias_method :delete_history_item, :delete
|
98
|
+
alias_method :get_audio_from_history_item, :get_audio
|
99
|
+
alias_method :download_history_items, :download
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
attr_reader :client
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElevenlabsClient
|
4
|
+
module Admin
|
5
|
+
class Models
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
# GET /v1/models
|
11
|
+
# Gets a list of available models
|
12
|
+
# Documentation: https://elevenlabs.io/docs/api-reference/models/list
|
13
|
+
#
|
14
|
+
# @return [Hash] The JSON response containing an array of models
|
15
|
+
def list
|
16
|
+
endpoint = "/v1/models"
|
17
|
+
@client.get(endpoint)
|
18
|
+
end
|
19
|
+
|
20
|
+
alias_method :list_models, :list
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :client
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -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
|