@mastra/voice-elevenlabs 0.12.0-beta.1 → 0.12.0-beta.2
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.
- package/CHANGELOG.md +18 -0
- package/dist/docs/README.md +32 -0
- package/dist/docs/SKILL.md +33 -0
- package/dist/docs/SOURCE_MAP.json +6 -0
- package/dist/docs/agents/01-adding-voice.md +352 -0
- package/dist/docs/voice/01-overview.md +1019 -0
- package/dist/docs/voice/02-reference.md +163 -0
- package/package.json +6 -6
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Voice API Reference
|
|
2
|
+
|
|
3
|
+
> API reference for voice - 2 entries
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Reference: ElevenLabs
|
|
9
|
+
|
|
10
|
+
> Documentation for the ElevenLabs voice implementation, offering high-quality text-to-speech capabilities with multiple voice models and natural-sounding synthesis.
|
|
11
|
+
|
|
12
|
+
The ElevenLabs voice implementation in Mastra provides high-quality text-to-speech (TTS) and speech-to-text (STT) capabilities using the ElevenLabs API.
|
|
13
|
+
|
|
14
|
+
## Usage Example
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import { ElevenLabsVoice } from "@mastra/voice-elevenlabs";
|
|
18
|
+
|
|
19
|
+
// Initialize with default configuration (uses ELEVENLABS_API_KEY environment variable)
|
|
20
|
+
const voice = new ElevenLabsVoice();
|
|
21
|
+
|
|
22
|
+
// Initialize with custom configuration
|
|
23
|
+
const voice = new ElevenLabsVoice({
|
|
24
|
+
speechModel: {
|
|
25
|
+
name: "eleven_multilingual_v2",
|
|
26
|
+
apiKey: "your-api-key",
|
|
27
|
+
},
|
|
28
|
+
speaker: "custom-speaker-id",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Text-to-Speech
|
|
32
|
+
const audioStream = await voice.speak("Hello, world!");
|
|
33
|
+
|
|
34
|
+
// Get available speakers
|
|
35
|
+
const speakers = await voice.getSpeakers();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Constructor Parameters
|
|
39
|
+
|
|
40
|
+
### ElevenLabsVoiceConfig
|
|
41
|
+
|
|
42
|
+
## Methods
|
|
43
|
+
|
|
44
|
+
### speak()
|
|
45
|
+
|
|
46
|
+
Converts text to speech using the configured speech model and voice.
|
|
47
|
+
|
|
48
|
+
Returns: `Promise<NodeJS.ReadableStream>`
|
|
49
|
+
|
|
50
|
+
### getSpeakers()
|
|
51
|
+
|
|
52
|
+
Returns an array of available voice options, where each node contains:
|
|
53
|
+
|
|
54
|
+
### listen()
|
|
55
|
+
|
|
56
|
+
Converts audio input to text using ElevenLabs Speech-to-Text API.
|
|
57
|
+
|
|
58
|
+
The options object supports the following properties:
|
|
59
|
+
|
|
60
|
+
Returns: `Promise<string>` - A Promise that resolves to the transcribed text
|
|
61
|
+
|
|
62
|
+
## Important Notes
|
|
63
|
+
|
|
64
|
+
1. An ElevenLabs API key is required. Set it via the `ELEVENLABS_API_KEY` environment variable or pass it in the constructor.
|
|
65
|
+
2. The default speaker is set to Aria (ID: '9BWtsMINqrJLrRacOk9x').
|
|
66
|
+
3. Speech-to-text functionality is not supported by ElevenLabs.
|
|
67
|
+
4. Available speakers can be retrieved using the `getSpeakers()` method, which returns detailed information about each voice including language and gender.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Reference: voice.getSpeakers()
|
|
72
|
+
|
|
73
|
+
> Documentation for the getSpeakers() method available in voice providers, which retrieves available voice options.
|
|
74
|
+
|
|
75
|
+
The `getSpeakers()` method retrieves a list of available voice options (speakers) from the voice provider. This allows applications to present users with voice choices or programmatically select the most appropriate voice for different contexts.
|
|
76
|
+
|
|
77
|
+
## Usage Example
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { OpenAIVoice } from "@mastra/voice-openai";
|
|
81
|
+
import { ElevenLabsVoice } from "@mastra/voice-elevenlabs";
|
|
82
|
+
|
|
83
|
+
// Initialize voice providers
|
|
84
|
+
const openaiVoice = new OpenAIVoice();
|
|
85
|
+
const elevenLabsVoice = new ElevenLabsVoice({
|
|
86
|
+
apiKey: process.env.ELEVENLABS_API_KEY,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Get available speakers from OpenAI
|
|
90
|
+
const openaiSpeakers = await openaiVoice.getSpeakers();
|
|
91
|
+
console.log("OpenAI voices:", openaiSpeakers);
|
|
92
|
+
// Example output: [{ voiceId: "alloy" }, { voiceId: "echo" }, { voiceId: "fable" }, ...]
|
|
93
|
+
|
|
94
|
+
// Get available speakers from ElevenLabs
|
|
95
|
+
const elevenLabsSpeakers = await elevenLabsVoice.getSpeakers();
|
|
96
|
+
console.log("ElevenLabs voices:", elevenLabsSpeakers);
|
|
97
|
+
// Example output: [{ voiceId: "21m00Tcm4TlvDq8ikWAM", name: "Rachel" }, ...]
|
|
98
|
+
|
|
99
|
+
// Use a specific voice for speech
|
|
100
|
+
const text = "Hello, this is a test of different voices.";
|
|
101
|
+
await openaiVoice.speak(text, { speaker: openaiSpeakers[2].voiceId });
|
|
102
|
+
await elevenLabsVoice.speak(text, { speaker: elevenLabsSpeakers[0].voiceId });
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Parameters
|
|
106
|
+
|
|
107
|
+
This method does not accept any parameters.
|
|
108
|
+
|
|
109
|
+
## Return Value
|
|
110
|
+
|
|
111
|
+
## Provider-Specific Metadata
|
|
112
|
+
|
|
113
|
+
Different voice providers return different metadata for their voices:
|
|
114
|
+
|
|
115
|
+
**OpenAI:**
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
**OpenAI Realtime:**
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
**Deepgram:**
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
**ElevenLabs:**
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
**Google:**
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
**Azure:**
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
**Murf:**
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
**PlayAI:**
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
**Speechify:**
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
**Sarvam:**
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
## Notes
|
|
158
|
+
|
|
159
|
+
- The available voices vary significantly between providers
|
|
160
|
+
- Some providers may require authentication to retrieve the full list of voices
|
|
161
|
+
- The default implementation returns an empty array if the provider doesn't support this method
|
|
162
|
+
- For performance reasons, consider caching the results if you need to display the list frequently
|
|
163
|
+
- The `voiceId` property is guaranteed to be present for all providers, but additional metadata varies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/voice-elevenlabs",
|
|
3
|
-
"version": "0.12.0-beta.
|
|
3
|
+
"version": "0.12.0-beta.2",
|
|
4
4
|
"description": "Mastra ElevenLabs voice integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,17 +27,16 @@
|
|
|
27
27
|
"elevenlabs": "^1.59.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@microsoft/api-extractor": "^7.52.8",
|
|
31
30
|
"@types/node": "22.13.17",
|
|
32
31
|
"@vitest/coverage-v8": "4.0.12",
|
|
33
32
|
"@vitest/ui": "4.0.12",
|
|
34
33
|
"eslint": "^9.37.0",
|
|
35
34
|
"tsup": "^8.5.0",
|
|
36
|
-
"typescript": "^5.
|
|
37
|
-
"vitest": "4.0.
|
|
38
|
-
"@internal/lint": "0.0.53",
|
|
35
|
+
"typescript": "^5.9.3",
|
|
36
|
+
"vitest": "4.0.16",
|
|
39
37
|
"@internal/types-builder": "0.0.28",
|
|
40
|
-
"@
|
|
38
|
+
"@internal/lint": "0.0.53",
|
|
39
|
+
"@mastra/core": "1.0.0-beta.20"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
42
|
"@mastra/core": ">=1.0.0-0 <2.0.0-0",
|
|
@@ -57,6 +56,7 @@
|
|
|
57
56
|
},
|
|
58
57
|
"scripts": {
|
|
59
58
|
"build": "tsup --silent --config tsup.config.ts",
|
|
59
|
+
"postbuild": "pnpx tsx ../../scripts/generate-package-docs.ts voice/elevenlabs",
|
|
60
60
|
"build:watch": "tsup build --watch && tsc -p tsconfig.build.json",
|
|
61
61
|
"test": "vitest run",
|
|
62
62
|
"lint": "eslint ."
|