@caleblawson/voice-elevenlabs
v0.10.3
Published
Mastra ElevenLabs voice integration
Readme
@mastra/voice-elevenlabs
ElevenLabs Voice integration for Mastra, providing Text-to-Speech (TTS) capabilities using ElevenLabs' advanced AI voice technology.
Installation
npm install @mastra/voice-elevenlabsConfiguration
The module requires the following environment variable:
ELEVENLABS_API_KEY=your_api_keyUsage
import { ElevenLabsVoice } from '@mastra/voice-elevenlabs';
// Initialize with configuration
const voice = new ElevenLabsVoice({
speechModel: {
name: 'eleven_multilingual_v2',
apiKey: 'your-api-key', // Optional, can use ELEVENLABS_API_KEY env var
},
speaker: 'Adam', // Default speaker
});
// List available speakers
const speakers = await voice.getSpeakers();
// Generate speech
const stream = await voice.speak('Hello from Mastra!', {
speaker: 'Adam', // Optional, defaults to constructor speaker
});Features
- High-fidelity Text-to-Speech synthesis
Voice Options
ElevenLabs provides a variety of premium voices with different characteristics:
- Adam (Male)
- Antoni (Male)
- Arnold (Male)
- Bella (Female)
- Dorothy (Female)
- Elli (Female)
- Josh (Male)
- Rachel (Female)
- Sam (Male)
View the complete list of voices through the getSpeakers() method or in ElevenLabs' documentation.
API Reference
Constructor
new ElevenLabsVoice({
speechModel?: {
name?: ElevenLabsModel, // Default: 'eleven_multilingual_v2'
apiKey?: string, // Optional, can use ELEVENLABS_API_KEY env var
},
speaker?: string // Default speaker ID
})Methods
getSpeakers()
Returns a list of available speakers with their details.
speak(input: string | NodeJS.ReadableStream, options?: { speaker?: string })
Converts text to speech. Returns a readable stream of audio data.
listen()
Not supported - ElevenLabs does not provide speech recognition.
