Back to Mastra

@mastra/voice-modelslab

voice/modelslab/README.md

2025-12-181.7 KB
Original Source

@mastra/voice-modelslab

ModelsLab voice integration for Mastra. Provides text-to-speech using ModelsLab's TTS API.

Installation

bash
npm install @mastra/voice-modelslab

Usage

typescript
import { ModelsLabVoice } from '@mastra/voice-modelslab';

const voice = new ModelsLabVoice({
  speechModel: {
    apiKey: process.env.MODELSLAB_API_KEY,
  },
  speaker: '5', // Female voice
});

// Text to speech
const audioStream = await voice.speak('Hello, world!', {
  speaker: 'nova', // OpenAI-style voices also work: alloy, echo, fable, onyx, nova, shimmer
  language: 'english',
  speed: 1.0,
});

// List available voices
const speakers = await voice.getSpeakers();

Configuration

OptionTypeDefaultDescription
speechModel.apiKeystringMODELSLAB_API_KEY envModelsLab API key
speakerstring'1'Default voice ID (1–6) or OpenAI voice name

Voice IDs

IDNameGender
1Neutralneutral
2Malemale
3Warmmale
4Deep Malemale
5Femalefemale
6Clear Femalefemale

OpenAI voice names are also accepted: alloy, echo, fable, onyx, nova, shimmer.

API Reference

See ModelsLab TTS docs for full API details.

ModelsLab uses key-in-body authentication (MODELSLAB_API_KEY) and asynchronous audio generation with polling.