ModelsLab
ModelsLab provides text-to-speech (TTS) only. The Mastra integration submits an asynchronous synthesis job, waits for the audio URL, downloads the completed audio, and returns it as a Node.js readable stream.
InstallationInstallation的直接链接
- npm
- pnpm
- Yarn
- Bun
npm install @mastra/voice-modelslab@latest
pnpm add @mastra/voice-modelslab@latest
yarn add @mastra/voice-modelslab@latest
bun add @mastra/voice-modelslab@latest
API keyAPI key的直接链接
Set MODELSLAB_API_KEY or pass the key through speechModel.apiKey. The constructor throws MODELSLAB_API_KEY is not set when neither value is available.
Usage exampleUsage example的直接链接
import { ModelsLabVoice } from '@mastra/voice-modelslab'
const voice = new ModelsLabVoice({
speechModel: {
apiKey: process.env.MODELSLAB_API_KEY,
},
speaker: '5',
})
const audioStream = await voice.speak('Hello, world!', {
speaker: 'nova',
language: 'english',
speed: 1,
})
const speakers = await voice.getSpeakers()
Constructor parametersConstructor parameters的直接链接
speechModel?:
name?:
apiKey?:
speaker?:
VoicesVoices的直接链接
ModelsLab exposes six built-in English voices:
| ID | Name | Gender | Language |
|---|---|---|---|
1 | Neutral | neutral | en |
2 | Male | male | en |
3 | Warm | male | en |
4 | Deep Male | male | en |
5 | Female | female | en |
6 | Clear Female | female | en |
OpenAI-style aliases map to these voices:
| Alias | Voice ID |
|---|---|
alloy | 1 |
echo | 2 |
fable | 3 |
onyx | 4 |
nova | 5 |
shimmer | 6 |
MethodsMethods的直接链接
speak()speak的直接链接
Converts text to speech. If ModelsLab returns a processing ID, the integration polls every five seconds for up to five minutes. It downloads the completed audio before returning the readable stream, so this method doesn't provide progressive audio streaming.
input:
options?:
speaker?:
language?:
speed?:
Returns: Promise<NodeJS.ReadableStream>
getSpeakers()getspeakers的直接链接
Returns the built-in ModelsLab voice metadata.
voiceId:
name:
language:
gender:
Returns: Promise<Array<{ voiceId: string; name: string; language: string; gender: string }>>
listen()listen的直接链接
ModelsLab doesn't support speech-to-text. Calling this method throws an error that points to @mastra/voice-deepgram as a listening provider.
Important notesImportant notes的直接链接
- ModelsLab text-to-speech requests send the API key in the request body.
- Processing jobs are polled every five seconds and time out after 300 seconds.
- The completed audio is fully downloaded before the stream is returned. The stream isn't progressive.
- The integration doesn't force an output format. It downloads the audio from the URL returned by ModelsLab.
speeddoesn't have runtime range validation in this package.- Non-numeric speaker values that don't match an alias fall back to voice ID
1. - Speech-to-text isn't supported.