Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:0xsline OpenChatCut VoiceGenerationPlugin

From Leeroopedia
Knowledge Sources
Domains AI_Generation, Voice_Synthesis, Provider_Integration
Last Updated 2026-10-22 14:00 GMT

Overview

Concrete Vite plugin that exposes `POST /generate/voice` for AI text-to-speech generation across multiple providers (ElevenLabs, MiniMax, Doubao, Inworld, Fish Audio, Speechify, and AI-SDK providers).

Description

The voiceGenerationPlugin function registers an HTTP endpoint for voice generation:

  • Request validation: `validateVoiceRequest` checks the provider, text, voice, and format.
  • Provider routing: Dispatches to the correct provider:
    • AI-SDK providers: `generateAiVoice` (uses Vercel AI SDK `generateSpeech`).
    • ElevenLabs: `elevenLabsVoice` (direct API).
    • MiniMax: `minimaxVoice` (returns audio + optional subtitle URL).
    • Doubao: `doubaoVoice`.
    • Inworld: `inworldVoice`.
    • Fish Audio: `fishAudioVoice`.
    • Speechify: `speechifyVoice`.
  • Audio saving: `saveVoiceAudio` writes the generated audio to the upload directory with the correct codec and sample rate.
  • Subtitle saving: If the provider returns a subtitle URL (MiniMax), `saveVoiceSubtitle` saves it.
  • Audio descriptor: `audioDescriptor` determines the codec and sample rate based on provider and format.

Usage

  • Voice generation UI: The editor calls this endpoint for TTS generation.
  • Agent voice generation: MCP agents generate voice-overs through this endpoint.

Code Reference

Source Location

  • Repository: OpenChatCut
  • File:*** server/plugins/voice.ts

Signature

export function voiceGenerationPlugin(options: VoiceOptions): Plugin;
export { validateVoiceRequest } from './voice-validation.ts';

Import

import { voiceGenerationPlugin } from '../server/plugins/voice.ts';

I/O Contract

Inputs (HTTP POST body — VoiceRequest)

Name Type Required Description
provider string Yes Provider name (elevenlabs, minimax, doubao, etc.)
text string Yes Text to synthesize
voice string Yes Voice ID
format string No Output format
outputFormat string No Provider-specific output format
audioFormat string No Audio format
sampleRate number No Sample rate

Outputs (HTTP 200 JSON)

Name Type Description
src string `/media/uploads/<name>` path to saved audio
subtitlePath string Optional: path to saved subtitle

Usage Examples

Generate Voice via HTTP

curl -X POST http://localhost:5199/generate/voice \
  -H 'Content-Type: application/json' \
  -d '{"provider":"elevenlabs","text":"Hello world","voice":"rachel"}'

Register the Plugin

import { voiceGenerationPlugin } from '../server/plugins/voice.ts';

const plugin = voiceGenerationPlugin({
  elevenLabsApiKey: process.env.ELEVENLABS_API_KEY,
  // ...other provider keys
});

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment