0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/voice/modelslab
History 2026-10-28 13:15:52 +00:00
..
src Extract voice internals from core (#16725) 2026-05-27 16:37:08 +02:00
CHANGELOG.md chore: version - exit prerelease mode 2026-10-28 13:15:52 +00:00
lint-staged.config.js refactor(lint): replace ESLint with type-aware oxlint (#27476) 2026-10-18 10:38:35 -07:00
package.json chore: version - exit prerelease mode 2026-10-28 13:15:52 +00:00
README.md docs: add MySQL, Gladia, and ModelsLab integrations (#22965) 2026-09-03 11:44:42 +02:00
tsconfig.build.json feat(voice): Add ModelsLab TTS voice provider (#13627) 2026-03-06 13:48:52 +01:00
tsconfig.json chore: migrate package builds to tsdown (#19829) 2026-07-28 12:32:21 +02:00
tsdown.config.ts chore: migrate package builds to tsdown (#19829) 2026-07-28 12:32:21 +02:00
vitest.config.ts feat(voice): Add ModelsLab TTS voice provider (#13627) 2026-03-06 13:48:52 +01:00

@mastra/voice-modelslab

ModelsLab text-to-speech integration for Mastra. It submits synthesis jobs to ModelsLab, waits for asynchronous generation to complete, downloads the result, and returns it as a Node.js readable stream.

Installation

npm install @mastra/voice-modelslab

Usage

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();

Documentation

See the ModelsLab voice integration guide and the Mastra Voice overview.

Pass the API key through speechModel.apiKey or set MODELSLAB_API_KEY. The constructor's speaker option sets the default voice and defaults to voice ID 1. Individual speak() calls can override the speaker, language, and speed.

The built-in voices are:

ID Name Gender
1 Neutral Neutral
2 Male Male
3 Warm Male
4 Deep Male Male
5 Female Female
6 Clear Female Female

OpenAI-style speaker aliases are also accepted: alloy, echo, fable, onyx, nova, and shimmer map to voice IDs 1 through 6 respectively. getSpeakers() returns the same voice metadata programmatically.

ModelsLab may return the audio URL immediately or a processing ID. The provider polls processing jobs every five seconds for up to five minutes, downloads the completed audio, and exposes it as a readable stream. This package does not implement speech-to-text; use a listening provider such as @mastra/voice-deepgram when transcription is required.

Changelog

See the package changelog for version history and release notes.

Support

We have an open community Discord. Come and say hello and let us know if you have any questions or need any help getting things running.