Speechify
The Speechify voice implementation in Mastra provides text-to-speech capabilities using Speechify's API.
Usage exampleDirect link to Usage example
import { SpeechifyVoice } from '@mastra/voice-speechify'
// Initialize with default configuration (uses SPEECHIFY_API_KEY environment variable)
const voice = new SpeechifyVoice()
// Initialize with custom configuration
const voice = new SpeechifyVoice({
speechModel: {
name: 'simba-english',
apiKey: 'your-api-key',
},
speaker: 'george', // Default voice
})
// Convert text to speech
const audioStream = await voice.speak('Hello, world!', {
speaker: 'henry', // Override default voice
})
Constructor parametersDirect link to Constructor parameters
speechModel?:
SpeechifyConfig
= { name: 'simba-english' }
Configuration for text-to-speech functionality
SpeechifyConfig
name?:
VoiceModelName
The Speechify model to use
apiKey?:
string
Speechify API key. Falls back to SPEECHIFY_API_KEY environment variable
speaker?:
SpeechifyVoiceId
= 'george'
Default voice ID to use for speech synthesis
MethodsDirect link to Methods
speak()Direct link to speak
Converts text to speech using the configured speech model and voice.
input:
string | NodeJS.ReadableStream
Text to convert to speech. If a stream is provided, it will be converted to text first.
options?:
Options
Configuration options.
Options
speaker?:
string
Override the default speaker for this request
model?:
VoiceModelName
Override the default model for this request
Returns: Promise<NodeJS.ReadableStream>
getSpeakers()Direct link to getspeakers
Returns an array of available voice options, where each node contains:
voiceId:
string
Unique identifier for the voice
name:
string
Display name of the voice
language:
string
Language code for the voice
gender:
string
Gender of the voice
listen()Direct link to listen
This method isn't supported by Speechify and will throw an error. Speechify doesn't provide speech-to-text functionality.
NotesDirect link to Notes
- Speechify requires an API key for authentication
- The default model is 'simba-english'
- Speech-to-text functionality isn't supported
- Additional audio stream options can be passed through the speak() method's options parameter