Documentation
VoxLabs is a local Python desktop application (PySide6) with an optional FastAPI REST API and Model Context Protocol (MCP) server. This manual covers every feature, page, model engine, DSP stage, database table, and API endpoint in VoxLabs 3.1.0.
1. Installation & Quick Start
You can install VoxLabs using the prebuilt standalone desktop archives (no Python installation needed) or run it from source using Python 3.12–3.13 and uv.
Option A: Standalone Desktop Bundles
- Open the download section or GitHub Releases and download the archive for your OS.
- Windows (10 or later, x64): Run
VoxLabs-Windows-x64-Setup.exe(no admin needed) or installVoxLabs-Windows-x64.msi. For a portable copy, extractVoxLabs-Windows-x64.zipand launchVoxLabs\VoxLabs.exe. - macOS (13 Ventura or later, Apple Silicon): Open
VoxLabs-macOS-arm64.dmgand dragVoxLabs.appto your Applications folder, or runVoxLabs-macOS-arm64.pkg. - Linux (x86_64): Ubuntu/Debian:
sudo apt install ./VoxLabs-Linux-x86_64.deb. Fedora:sudo dnf install ./VoxLabs-Linux-x86_64.rpm. Then start VoxLabs from the app menu or runvoxlabs. For a portable copy, extractVoxLabs-Linux-x86_64.tar.gzand runVoxLabs/VoxLabs. - Because community builds are not code-signed with a commercial certificate yet, confirm the first launch if Windows SmartScreen or macOS Gatekeeper prompts you.
Audio formats: WAV, FLAC, OGG, and MP3 work out of the box via libsndfile. Having ffmpeg on your system PATH is optional and enables M4A/AAC import and export.
Option B: Run from Source with uv
git clone https://github.com/nishanth-kj/VoxLabs.git cd VoxLabs # Base install (includes PySide6 UI, FastAPI, MCP, DSP enhancement, and MFCC voice profiles) uv sync # Recommended fast offline neural TTS engines (run well on CPU or GPU) uv sync --extra piper --extra kokoro # Optional heavy zero-shot cloning engines (mutually exclusive PyTorch dependencies; pick one): uv sync --extra chatterbox # Chatterbox TTS (MIT, zero-shot cloning + native emotion) # Start the desktop application uv run python -m app.main
First launch: Open the Models page and click Download All (or install Piper · en_US Lessac, 63 MB). Model weights are fetched directly from Hugging Face and stored under data/models/, even if a model's Python extra has not been installed yet. On slow connections, increase uv's timeout before syncing PyTorch wheels (e.g. in PowerShell: $env:UV_HTTP_TIMEOUT = "900"; uv sync --extra piper).
Environment Variables
| Variable | Effect |
|---|---|
| VOXLABS_DATA_DIR | Where the database, audio, voices, models, cache, and logs live (default ./data) |
| VOXLABS_DB_PATH | Override only the SQLite database file path (default data/database/voxlabs.db) |
| VOXLABS_API_TOKEN | Require a Authorization: Bearer <token> header on the REST API and HTTP MCP server |
| LOG_LEVEL | Initial log level: DEBUG, INFO, WARNING, or ERROR (the Settings page can also change it) |
2. Desktop Studio Pages & Keyboard Shortcuts
The VoxLabs window follows a modern VS Code–inspired layout:
- Title Bar & Command Center: Displays the VoxLabs logo, the full application menu bar (File, Edit, View, Voice, Audio, Script, Tools, Help), a central search button that opens the Command Palette, and native-snapping window controls. Enable Settings → Appearance → Use the system title bar if you prefer your OS's native window frame.
- Every Command in the Menu & Palette: Every action on every page is reachable from the top menu bar and searchable in the Command Palette (
Ctrl+Shift+PorF1). Selecting a page command automatically navigates to that page and invokes its action. - Status Bar & Live Logs Panel: The bottom status bar shows the REST API / MCP server state (click to start or stop), active background jobs, and the Logs toggle (
Ctrl+`) with live warning/error counts and source filters (ui,api,mcp,system).
Pages Reference
| Page | What It Does |
|---|---|
| Home (Ctrl+1) | Quick-start workflow cards, recent generated/imported audio library, and one-click navigation into the editor or studio. |
| Studio (Ctrl+2) | One script at a glance: section list, voice inspector, multi-take selector, interactive clip timeline over the rendered waveform, and transport controls. |
| Clone Voice (Ctrl+3) | Guided workflow: import or record reference samples → automatic quality analysis table → attributed speaker consent form → cloning model picker → preview & save. |
| Generate Speech (Ctrl+4) | Single or multi-sentence TTS with voice, built-in engine_voice, model, emotion, style, speed, pitch, energy, temperature, seed, inline pauses, pronunciations, and sentence regeneration. |
| Script to Audio (Ctrl+5) | Plain-text script & lesson editor (autosaves after 0.8 s) with Structure, Speakers, Section overrides, and Script settings tabs. |
| Audio Editor (Ctrl+6) | Non-destructive waveform editor with selection, cut/copy/paste/delete, trim, split, move, duplicate, join, silence, fade, gain, normalize, 8-stage DSP enhance, undo/redo, and loop playback. |
| Voices (Ctrl+7) | Cloned voices plus every built-in preset: Piper Lessac (the default voice), all 54 Kokoro voices, all 9 Qwen3-TTS voices, and the Edge neural catalog. Preview, edit, export metadata, revoke, or delete. |
| Models (Ctrl+8) | Download weights directly from Hugging Face (single model or Download All), load/unload into CPU or CUDA memory, run health checks, set defaults, and rescan data/models/. |
| Voice Editor (Ctrl+9) | Edit a voice’s name, model, engine voice, and delivery (speed, pitch, energy, emotion, style). Preview it, then use that saved voice in Generate and script-to-audio. |
| Files (Ctrl+0) | One place for every audio file: generated, imported, processed and edited audio, every export with its format and bitrate, and reference voice samples. Open folders, copy paths, play or re-edit. |
| MCP | Inspect the embedded Model Context Protocol server: live activity log of every tool call from AI apps, real-time duration, argument inspector, and copyable configs for Claude Desktop and Claude Code. |
| Settings (Ctrl+,) | Configure default TTS/cloning models, compute device (auto/cpu/cuda), performance hardware presets, online engine opt-in, editor autosave, appearance/theme, native title bar, and embedded REST API + MCP server. |
Keyboard Shortcuts
| Shortcut | Command |
|---|---|
| Ctrl+Shift+P / F1 | Open the Command Palette to search and trigger any menu command |
| Ctrl+1 … Ctrl+0 | Switch between Home, Studio, Clone, Generate, Script, Editor, Voices, Models, Voice Editor, and Files (Ctrl+0) |
| Ctrl+0 | Open the Central Audio Library / Files page |
| Ctrl+, | Open Settings |
| Ctrl+B | Collapse or expand the navigation sidebar |
| Ctrl+` | Toggle the bottom live Logs panel (with source filter & warning/error badges) |
| Ctrl+J | Open the Background Jobs monitor dialog |
| Ctrl+N | Create a new script on the Script to Audio page |
| Ctrl+O / Ctrl+I | Open an existing audio or import an audio file into the Audio Editor |
| Space | Play / Pause transport in the Audio Editor |
| Ctrl+Z / Ctrl+Shift+Z | Undo / Redo in focused text input or non-destructive Audio Editor |
| Ctrl+X / Ctrl+C / Ctrl+V / Del | Cut, Copy, Paste, or Delete selection in text box or Audio Editor |
| Ctrl+D / Ctrl+T | Duplicate selection or Trim (crop) to selection in the Audio Editor |
| Ctrl+S / Ctrl+E | Render pending edits as a new audio row / Export audio to WAV, FLAC, OGG, MP3, or M4A |
| F11 / Ctrl+Q | Toggle Full Screen / Exit VoxLabs |
3. Architecture, Packages & Background Work
VoxLabs is organized into a single Python package, app/, with strict separation of concerns. The PySide6 UI, the FastAPI REST routes, and the MCP tools all call the same service singletons—never touching SQLite or AI model backends directly.
PySide6 UI (app/ui) REST API + MCP (app/api) ← optional interfaces
\ /
Services (app/services) ← all application logic & transactions
/ \
Models (app/models) Utils (app/utils)
\ /
SQLite + files under data/Package Map
| Package | Responsibilities |
|---|---|
| app/main.py | Desktop entry point: initialize services, create QApplication and MainWindow, optionally start the embedded REST API + MCP server. |
| app/services/ | One service per domain: user, voice, clone, consent, tts, script, audio, model, job, system. Each exposes a module singleton (tts_service, …). |
| app/models/ | SQLAlchemy 2.0 tables (one file per table, no commits or workflow logic). models/request/ and models/response/ hold Pydantic request classes and ApiResponse. |
| app/utils/ | Technical infrastructure: database (engine, transaction(), serialize()), audio (I/O and DSP), ffmpeg, files, device, validation (Validation), model (AI backends), hashing, time, logger. |
| app/constants/ | Fixed values and BaseEnum classes: base_enum, status, consent_status, response_status, error_code, error_message, audio_source, model_type, model_backend, audio, jobs, models. |
| app/exceptions/ | AppError and subclasses (ValidationError, NotFoundError, ConsentError, VoiceError, AudioError, ModelError, JobError, AuthError, InternalError) + service_error(). |
| app/api/ | FastAPI app (app.py), thin routers in routes/, and MCP server in mcp/ (tools.py, served over streamable HTTP at /mcp and over stdio with --stdio). |
| app/ui/ | main_window.py, 10 pages, shared widgets (title_bar, nav_bar, command_palette, player, waveform, timeline, log_panel, job_status), app_menu.py, theme.py, and icons.py. |
How a Request Flows
- Clicking Generate on the Generate page builds a
TTSRequestand callstts_service.generate_async(body)(orPOST /api/tts/ MCPgenerate_speechcallstts_service.generate(body)). JobService.submit()records ajobsrow (status = Pending) and dispatches the work on a background thread pool.TTSService.generate()validates input, resolves the voice viaVoiceService.voice_ref()(checking consent), resolves the model viaModelService.resolve_speech_model(), loads the backend, synthesizes chunk-by-chunk, applies prosody and DSP clean-up, and registers anaudiosrow inside a single transaction.- Job progress and completion are written to SQLite and pushed to listeners.
JobBridgeturns updates into Qt signals soBasePage.follow()updates the progress bar on the UI thread without ever blocking Qt.
Errors & Logging: Every public service method wraps its body in try: ... except Exception as exc: raise service_error(exc, "<service>.<method>"). Known AppError subclasses pass through; unexpected exceptions are logged once with their traceback and converted into InternalError. app/utils/logger.py writes to stderr (keeping stdout clean for MCP stdio), the memory buffer for the bottom Logs panel, and rotating files in data/logs/voxlabs.log. Audio content, file bytes, and credentials are never logged.
4. Voice Cloning & Consent Lifecycle
Voice cloning is managed by CloneService, ConsentService, and VoiceService. Explicit, attributed consent is verified before any sample is processed.
samples → validate files → validate consent → select model
→ analyze + prepare samples (staging folder) → build profile
→ [one transaction: create voice → record consent → move samples in → store profile]
→ voice ready for TTS → preview- Validate files (
require_audio_file): Verifies each file exists, is non-empty, and has a supported extension (wav,mp3,flac,ogg,m4a,aac,opus). - Validate consent (
ConsentService.validate): Requiresconfirmed is True, plus non-emptygranted_byandspeaker_name. Runs before any audio work; nothing can bypass it. - Select model: Uses the requested
model_keyordefault_clone_modelfrom Settings (must be an installedCLONEorEMBEDmodel). - Analyze (
analyze_sample): RunsAudioService.analyzeand blocks on samples shorter than 1 s or longer than 5 min, sample rates under 16 kHz, or more than 90% silence. Clipping, high noise floor, and low level are reported as warnings. - Prepare samples: Resamples each file to 24 kHz mono, trims leading/trailing silence, peak-normalizes to −1 dBFS, and writes to a staging folder. Combined samples must provide at least 3 seconds of speech.
- Build profile (
build_profile): Computes 13-band MFCC mean/std vectors and median fundamental frequency (pYIN) across all prepared samples. - Atomic transaction: Creates the
voicesrow, records thevoice_consentsrow, moves prepared samples intodata/voices/<voices_id>/samples/, and stores the profile. On any error, the database transaction rolls back and both staging and voice folders are removed.
Zero-Shot vs. Profile vs. Preset
Chatterbox, Chatterbox Turbo, Qwen3-TTS: Receive stored reference WAV paths for true zero-shot voice cloning (params.cloned = true).
Voice Profile (MFCC): Speaks through the default TTS model and shifts output pitch to match the speaker's median pitch (params.pitch_matched = true).
Preset Voices: Built-in engine speakers (e.g. Kokoro, Qwen3-TTS or Edge engine_voice, or the Chatterbox models' own voice); nobody is cloned, so consent_status = NotRequired.
Revoking vs. Deleting a Voice
Revoke (voice_service.revoke): (1) Deletes all sample files and the profile from disk, (2) marks consent rows Inactive with revoked_at, (3) sets voices.status = Inactive and consent_status = Revoked, and (4) blocks the voice from synthesis while keeping the row as an audit trail.
Delete (voice_service.delete): Removes the voice row, sample rows, consent rows, and disk folder completely.
5. Text to Speech (TTS) & Model Engines
text → validate → pronunciations → resolve voice → resolve model → load backend
→ chunk (sentence-aligned, [pause] tags; ≤ 400 chars, or the engine's own limit)
→ synthesize each chunk (one generation at a time per engine)
→ join with pauses → pitch-match (profile voices) → prosody DSP
→ save original WAV → clean-up steps → processed WAV → audios row (ai_generated)- Deterministic Cache (
cache: true): Hashes text, speech parameters, resolved model, and voice update timestamp; returns the newest matching generated audio whose file still exists on disk withcached: true. - GPU OOM → CPU Fallback: When a model runs out of CUDA memory while loading (e.g. when a local LLM is running), VoxLabs frees CUDA cache and reloads the model on CPU automatically.
- Fallback Models: When no model is explicitly requested and
default_tts_modelis not installed, VoxLabs uses the first installed model inFALLBACK_TTS_MODELS(chatterbox→chatterbox-turbo→qwen3-tts-0.6b→kokoro-82m→piper-en-us-lessac-medium). - Sentence-Level Regeneration:
generate_sentences(text)creates one audio per sentence plus a joined result;regenerate_sentence(audios_ids, index)re-synthesizes a single sentence and rebuilds the joined audio.
TTS Parameters
| Parameter | Range / Type | Notes |
|---|---|---|
| voices_id | int | null | Cloned or preset voice ID. Omit it to use the engine's default voice. |
| engine_voice | short id | One of the engine's built-in voices, e.g. Kokoro af_heart / af_bella / bm_george, Qwen3-TTS ryan / aiden / vivian / serena, or an Edge short name. Overrides the voice's own engine_voice. |
| model_key | string | null | Resolved in order: explicit key → voice's own cloning model (if installed) → default_tts_model → first installed fallback model. |
| speed, pitch | 0.5 – 2.0 | Passed to the engine when supported natively; otherwise applied with float64 phase-vocoder DSP. |
| energy | 0.1 – 2.0 | Output gain multiplier with automatic peak protection. |
| emotion | 8 presets | neutral, happy, sad, angry, calm, excited, fearful, confident. Preset multiplier on speed/pitch/energy; Chatterbox handles emotion natively. |
| style | 6 presets | default, narration, conversational, lecture, news, storytelling. Adjusts speed and inter-sentence pause. |
| pause_ms | ≥ 0 ms | Gap between chunks. You can also write [pause 800ms] or [pause 2s] inline in the text. |
| pronunciations | {word: spoken} | Whole-word case-insensitive replacement applied before synthesis. |
| temperature | 0.1 – 1.5 | Sampling temperature (Chatterbox, Chatterbox Turbo and Qwen3-TTS only). |
| seed | int | Deterministic generation seed (Chatterbox, Chatterbox Turbo and Qwen3-TTS only). |
| post / preset | steps | name | Clean-up DSP steps or preset name. Default is trim_silence + normalize; {} means raw output. |
| cache | bool | When true, returns an identical earlier generation matching text + settings + model + voice hash without re-synthesizing. |
Engines Reference
| Backend | Install | Execution | Native Capabilities |
|---|---|---|---|
| Piper | uv sync --extra piper + install on Models page | Local CPU / GPU (63 MB) | speed; direct ONNX weight download |
| Kokoro 82M | uv sync --extra kokoro + install on Models page | Local CPU / GPU (330 MB) | speed; built-in voices via engine_voice (default af_heart) |
| Chatterbox | uv sync --extra chatterbox (MIT) | Local GPU rec. / CPU fallback (3.20 GB) | emotion, temperature, seed; zero-shot cloning or built-in voice |
| Chatterbox Turbo | uv sync --extra chatterbox (MIT, same package) | Local GPU rec. / CPU fallback (2.99 GB) | temperature, seed; faster zero-shot cloning (sample over 5 s) or built-in voice |
| Qwen3-TTS 0.6B | Install on Models page (Apache-2.0; sets up its own engine environment with uv) | Local helper process (4.15 GB: Base + CustomVoice) | temperature, seed; zero-shot cloning or 9 built-in voices via engine_voice (default ryan), 10 languages |
| Voice Profile (MFCC) | Built into base install (librosa) | Local CPU | Extracts MFCC + pYIN median pitch; pitch-matches default TTS output |
| Emotional (gTTS) | Built into base install | Online (Google), opt-in only | Shaped with local prosody DSP afterwards |
| Edge Neural | Built into base install | Online (Microsoft), opt-in only | speed, pitch; preset voices via engine_voice (default en-US-AriaNeural) |
6. Script & Lesson to Audio
ScriptService turns scripts, lessons, and multi-speaker dialogues into narrated audio with automatic chapter/section structure and per-section take management.
Lesson 1 ← chapter (Lesson/Chapter/Part/Unit/Module …, or "# Title")
Introduction ← heading (Section/Topic/Scene/Introduction/Summary/Example …,
"## Title", or a short Title Case line)
Welcome to today's lesson. ← paragraph → one section
Teacher: What is a wave? ← speaker line → one section (speaker "Teacher")
Student: I'm not sure.
It sounds hard. ← continues the Student line
[pause 2s] ← a line on its own adds pause after the previous section- Automatic Pauses:
parse_script(body, speak_headings=False)inserts 600 ms between paragraphs, 1200 ms at chapter/heading boundaries, plus any manual[pause …]lines. Withspeak_headings=True, headings are spoken aloud as sections. - 5-Step Voice Resolution Order: (1) Section's own
voices_id→ (2)speaker_map[speaker]→ (3)speaker_map["*"](narrator) → (4)default_voices_idsetting → (5) Engine's default voice. Useauto_map_speakers()to assign available voices round-robin. - Script Settings: Stored in
scripts.settings:model_key,speed,emotion,style, final masteringpreset,speak_headings,intro_text, andoutro_text. - Smart Takes & Rendering: Editing the script body re-parses it while keeping existing takes for any section whose
(speaker, text)did not change.render(scripts_id)joins all selected takes with each section's pause, adds optional intro/outro, applies the final clean-up preset (e.g. Lesson at −16 LUFS), and stores the result asscripts.final_audios_id.
7. Audio Engine, DSP Pipeline & Waveform Editor
AudioService and app/utils/audio.py process audio as mono float32 and store working copies as 16-bit WAV. No operation ever overwrites an existing file:
- Import: Copies the source file to
audios.original_pathand writes a WAV working copy toaudios.path. - Processing & Rendered Edits: Create a new
audiosrow withparent_audios_idpointing to the source audio. - Editor Autosave: Stores the pending non-destructive operation list directly on the audio row (
audios.edit_opsviaaudio_service.save_edit_ops), so edits persist for every audio file. - Export & AI Labelling:
export(audios_id, dest, fmt, sample_rate)writes WAV, FLAC, OGG, or MP3 vialibsndfileand M4A via FFmpeg. AI-generated audio is tagged withcomment="AI-generated by VoxLabs"andsoftware="VoxLabs".
8-Stage Enhancement Pipeline
Steps always execute in this fixed order: trim_silence → denoise → eq → compress → deess → normalize → limit → loudness. Passing {"step": null} disables a step from a preset.
| Step | Implementation | Options |
|---|---|---|
| 1. trim_silence | Frame RMS threshold with leading/trailing padding | threshold_db, pad_ms |
| 2. denoise | STFT spectral gating against the quietest 15% of frames | strength (0 – 1) |
| 3. eq | RBJ biquad high-pass, presence peak (3 kHz), low peak, high shelf | highpass_hz, presence_db, low_db, high_db |
| 4. compress | RMS envelope follower with static compression curve | threshold_db, ratio, makeup_db |
| 5. deess | High-band (6 kHz) dynamic sibilance reduction | frequency, threshold_db, ratio |
| 6. normalize | Peak amplitude normalization | peak_db |
| 7. limit | 5 ms peak-hold gain envelope followed by hard ceiling | ceiling_db |
| 8. loudness | K-weighted BS.1770-style gated loudness gain, then limiter | target_lufs, ceiling_db |
Built-In Enhancement Presets
| Preset | Processing Chain |
|---|---|
| Raw | No DSP steps applied; preserves the exact raw waveform. |
| Voice Clean | Trims silence, applies gentle spectral denoise, high-pass filter, and peak normalization. |
| Podcast | Denoise, presence EQ boost, vocal compression, de-esser, limiter, and −16 LUFS broadcast loudness. |
| Narration | Warm EQ, smooth compression, de-esser, and −18 LUFS audiobook/narration loudness. |
| Lesson | Clear speech intelligibility EQ, compression, and −16 LUFS loudness for educational content. |
| Studio | Full 8-stage vocal mastering chain targeting −14 LUFS. |
Non-Destructive Editor Operations (apply_edit_ops)
| op | Fields (seconds) | Description |
|---|---|---|
| delete / cut | start, end | Remove the selected time range (cut also saves the selection to a clip). |
| crop / trim | start, end | Keep only the selected time range and discard the rest. |
| insert / paste | at, clip | Insert a saved WAV clip from save_clip() at the cursor timestamp. |
| append | clip, gap | Join another audio file onto the end with an optional silence gap. |
| silence | at, duration | Insert pure silence of duration seconds at the cursor. |
| duplicate | start, end | Copy the selected region immediately after itself. |
| move | start, end, to | Cut the selected region and insert it at timestamp to. |
| gain / volume | start, end, db | Apply decibel gain adjustment over the selected region. |
| fade_in / fade_out | start, end | Apply a smooth fade-in or fade-out ramp over the selection. |
| normalize | start, end, peak_db | Peak-normalize the selected region to peak_db. |
| enhance | start, end, steps | preset | Run any DSP preset or custom step dictionary on the selected region. |
8. Database Schema, Status Enum & Transactions
VoxLabs uses SQLite through SQLAlchemy 2.0 (data/database/voxlabs.db) with WAL journaling and foreign keys enabled. Every table uses a plural name, an explicit <table>_id integer primary key, an integer status column backed by BaseEnum (Status.ACTIVE.code == 1, INACTIVE == 2, PENDING == 3, IN_PROGRESS == 4, COMPLETED == 5, FAILED == 6, CANCELLED == 7, DELETED == 8), plus timezone-aware UTC created_at and updated_at timestamps.
In-place upgrades: init_db() runs create_all() followed by idempotent steps in _upgrade(engine) (such as adding audios.edit_ops and removing the old projects table and columns).
| Table | Purpose | Columns |
|---|---|---|
| users | Local operator profiles | users_id, name, email, status, created_at, updated_at |
| voices | Cloned or preset voices | voices_id, users_id, name, language, model_key, source (clone/preset), engine_voice, consent_status, profile (JSON), storage_dir, sample_count |
| voice_samples | Reference recordings | voice_samples_id, voices_id, path, duration, sample_rate, quality (JSON), sha256 |
| voice_consents | Consent audit trail | voice_consents_id, voices_id, granted_by, speaker_name, statement, granted_at, revoked_at |
| audios | Every audio file | audios_id, parent_audios_id, path, original_path, source, ai_generated, duration, sample_rate, channels, format, codec, file_size, loudness, params (JSON), edit_ops (JSON) |
| scripts | Scripts and lessons | scripts_id, title, body, speaker_map, settings, final_audios_id |
| script_sections | Generatable script units | script_sections_id, scripts_id, position, chapter, heading, speaker, text, voice/speed/pitch/emotion/style overrides, pause_after_ms |
| takes | Renditions of a section | takes_id, script_sections_id, audios_id, take_number, selected |
| jobs | Background work records | jobs_id, users_id, job_type, title, progress, error, params, result, started_at, finished_at |
| models | Model catalog state | models_id, key, name, model_type, backend, version, size_mb, vram_mb, capabilities, online, installed_path |
| exports | Exported files registry | exports_id, audios_id, path, format, duration, file_size, status, created_at, updated_at |
| mcp_calls | MCP tool invocation audit log | mcp_calls_id, tool_name, arguments (JSON), result (JSON), error, duration_ms, source, status, created_at, updated_at |
9. REST API & Model Context Protocol (MCP) Server
The REST API and MCP server expose the exact same services as the desktop app. Start them from Settings → REST API (or Tools → Run REST API and MCP Server) inside the desktop app, or run them from the command line:
uv run python -m app.api.app # REST + MCP over HTTP on 127.0.0.1:8942 (Swagger at /docs, MCP at /mcp) uv run python -m app.api.app --stdio # Same HTTP server + MCP over stdin/stdout for local MCP clients uv run uvicorn app.api.app:app --reload # Development server on 127.0.0.1:8000
Response Envelope, Single Save Endpoint & Error Codes
Every API response—including errors—returns HTTP 200 with the uniform ApiResponse JSON envelope (status: 1 for success, 0 for error). Each CRUD resource has a single POST /api/<resource> save endpoint: omit <table>_id to create, pass <table>_id to update, or pass <table>_id + "status": 8 (Status.DELETED.code) to delete.
{ "status": 1, "data": { ... }, "error": null }
{ "status": 0, "data": null, "error": {
"error_code": 404,
"error_message": "The requested item was not found.",
"field": { "voices_id": "Voice 42 not found" }
} }| error_code | Exception Class | Meaning |
|---|---|---|
| 400 | AppError, AudioError | Bad request or invalid domain operation |
| 401 | AuthError | Missing or invalid bearer API token |
| 403 | ConsentError | Missing, invalid, or revoked speaker consent |
| 404 | NotFoundError | Requested record or route was not found |
| 409 | VoiceError, JobError | Conflict with current voice or job state |
| 422 | ValidationError | Invalid request field(s); field maps each field name to its message |
| 500 | InternalError | Unexpected exception (logged once via service_error(); stack traces are never returned) |
| 503 | ModelError | Model not installed, online engines disabled, or model load failure |
All REST Endpoints
| Method & Path | Request Class | Service Call |
|---|---|---|
| GET /api/health, GET /api/presets | — | system_service.health() / presets() |
| POST /api/performance/preset | PerformancePresetRequest | system_service.apply_preset(name) |
| GET /api/users, GET /api/users/{id} | — | user_service.list_users() / get_user() |
| POST /api/users | UserRequest | user_service.save(body) (create / update / delete) |
| GET /api/voices, GET /api/voices/{id} | — | voice_service.list_voices() / get() |
| POST /api/voices | VoiceRequest | voice_service.save(body) (creates/updates/deletes preset voices) |
| POST /api/voices/clone | CloneRequest (multipart) | clone_service.clone_upload(body) |
| POST /api/voices/analyze | multipart sample | clone_service.analyze_upload() |
| POST /api/voices/{id}/revoke, GET .../export | — | voice_service.revoke() / export_metadata() |
| POST /api/voices/{id}/samples, POST .../samples/{sid}/remove | multipart audio | voice_service.attach_upload() / remove_sample() |
| POST /api/tts | TTSRequest | tts_service.generate(body) / generate_async(body) |
| POST /api/tts/regenerate | RegenerateRequest | tts_service.regenerate(body) |
| GET /api/scripts, GET /api/scripts/{id} | — | script_service.list_scripts() / get() |
| POST /api/scripts | ScriptRequest | script_service.save(body) |
| POST /api/scripts/{id}/generate | GenerateScriptRequest | script_service.generate(id, body) / generate_async(id, body) |
| POST /api/scripts/sections | SectionRequest | script_service.update_section(body) |
| POST /api/scripts/sections/{id}/generate, POST .../takes/{id}/select | — | script_service.generate_section() / select_take() |
| GET /api/audio, GET /api/audio/{id}, GET /api/audio/{id}/file | — | audio_service.list_audios() / get() / file download |
| GET /api/library | — | audio_service.list_library() (all audios, exports, samples) |
| POST /api/audio/import | AudioImportRequest (multipart) | audio_service.import_upload(body) |
| POST /api/audio/process | AudioProcessRequest | audio_service.process(body) (steps/preset or editor ops list) |
| POST /api/audio/export | AudioExportRequest | audio_service.export(body), returns the exported file |
| GET /api/exports | — | export_service.list_exports() |
| GET /api/models, GET /api/models/{id}, GET .../health | — | model_service.list_models() / get() / health() |
| POST /api/models/install-all | — | model_service.install_all_async() |
| POST /api/models/{id}/install | load | unload | — | model_service.install_async() / load_async() / unload() |
| GET /api/jobs, GET /api/jobs/{id}, POST /api/jobs/{id}/cancel | — | job_service.list_jobs() / get_job() / cancel() |
MCP Server Tools & Client Configuration
MCP tools in app/api/mcp/tools.py take the same Pydantic request classes and return the same {status, data, error} envelope. Voice cloning is intentionally omitted from MCP so consent always comes directly from a human speaker.
| Domain | MCP Tool Names |
|---|---|
| System & Users | health, presets, apply_performance_preset, list_users, save_user |
| Voices & Speech | list_voices, get_voice, save_voice, generate_speech, regenerate_speech |
| Audio, Library & Exports | list_audio, get_audio, process_audio, export_audio, list_library, list_exports |
| Scripts | list_scripts, get_script, save_script, update_section, generate_script |
| Models & Jobs | list_models, list_jobs, get_job, cancel_job |
// MCP Client Config (Claude Desktop / Cursor / Windsurf / VS Code)
{
"mcpServers": {
"voxlabs": {
"command": "uv",
"args": ["run", "--directory", "C:/Projects/VoxLabs", "python", "-m", "app.api.app", "--stdio"]
}
}
}
# cURL Examples:
# 1. Create, update, and delete a user with the single save endpoint
curl -s -X POST 127.0.0.1:8942/api/users -H 'Content-Type: application/json' -d '{"name": "Ada"}'
curl -s -X POST 127.0.0.1:8942/api/users -H 'Content-Type: application/json' -d '{"users_id": 1, "email": "ada@example.com"}'
curl -s -X POST 127.0.0.1:8942/api/users -H 'Content-Type: application/json' -d '{"users_id": 1, "status": 8}'
# 2. Generate speech with emotion and built-in Kokoro voice
curl -s -X POST 127.0.0.1:8942/api/tts -H 'Content-Type: application/json' \
-d '{"text": "Hello from VoxLabs.", "emotion": "calm", "engine_voice": "af_heart"}'
# 3. Clone a voice (consent fields are mandatory)
curl -s -X POST 127.0.0.1:8942/api/voices/clone \
-F name="Narrator" -F consent=true -F granted_by="Jane Doe" -F speaker_name="Jane Doe" \
-F samples=@jane.wav
# 4. Render a script in the background and poll the job
curl -s -X POST 127.0.0.1:8942/api/scripts/1/generate -H 'Content-Type: application/json' -d '{}'
curl -s 127.0.0.1:8942/api/jobs/1210. Development, Testing & Adding Engines
uv run pytest # Full suite (offscreen Qt + API + MCP + DSP, 0 warnings enforced) uv run pytest tests/test_script_service.py -k render uv run python scripts/build.py # Build standalone PyInstaller bundle into dist/VoxLabs/ docker build -t voxlabs-api --build-arg EXTRAS="piper kokoro" .
Adding a Feature
- Put logic in the service, validate with
Validation, raiseAppErrorsubclasses, and wrap inservice_error(). - Wrap multi-row writes in one
with transaction() as session:block. - Add a
*_asyncwrapper usingjob_service.submit()for slow operations. - Wire to UI via
BasePage.run()/follow(), REST viaapp/api/routes/returningApiResponse(data).success(), and MCP viaapp/api/mcp/tools.py.
Adding a Model Engine
- Add an entry to
MODEL_CATALOGinapp/constants/models.py(with direct Hugging FacefilesURLs if applicable). - Subclass
ModelBackendinapp/utils/model.py(lazy import insideload(), implementsynthesize()). - Register the class in
_BACKENDS. - Add the optional dependency extra in
pyproject.tomland runuv lock.
Safety & Privacy Guarantees
Processing is local. Voice samples are never silently uploaded to external servers, online engines are opt-in only, every generated file is tagged AI-generated by VoxLabs, and revoking consent deletes voice data immediately. Read our Privacy Policy and Ethical AI Guidelines.