Skip to main content

Piper TTS voice manager library with interactive TUI

Project description

VoxKit

pip CI PyPI Downloads voxkit GitHub repo Coverage Status LICENSE GPLv3

A Python library for managing Piper TTS voice models. Browse, install, and use offline AI voices with a clean API and an interactive terminal UI.

Features

  • Voice catalog — list, search, and filter Piper voices by language or locale
  • Install/uninstall — download voice models to any directory you choose
  • TTS synthesis — synthesize text to WAV files with volume control
  • Interactive TUI — terminal-based voice browser with install, uninstall, and test
  • Configurable — custom data directories, catalog URLs, cache TTL, and TUI keybindings
  • Offline — all synthesis runs locally, no internet needed after voice download

Requirements

  • Python 3.10+
  • Linux (uses aplay for WAV playback, mpg123 for MP3)
  • Piper TTS (installed automatically as dependency)

Installation

pip install voxkit

Quick Start

from voxkit import VoiceManager

# Initialize with your app's storage directory
vm = VoiceManager(data_dir="~/.myapp/voices")

# List available English voices
voices = vm.list_voices("en")
for v in voices:
    print(f"{v['key']}  {v['quality']}  {v['size_mb']:.0f} MB  {'[installed]' if v['installed'] else ''}")

# Install a voice
vm.install("en_US-lessac-medium")

# Synthesize and play text
vm.speak("en_US-lessac-medium", "Hello, world!")

API Reference

VoiceManager

VoiceManager(
    data_dir,             # Directory for models and cache
    catalog_url=None,     # Override Piper catalog URL
    base_url=None,        # Override download base URL
    cache_ttl=86400,      # Catalog cache TTL in seconds (default: 24h)
)

Catalog

vm.list_languages()                # -> ['en', 'pl', 'de', ...]
vm.get_language_name("en")         # -> 'English'
vm.list_voices("en")               # all English variants
vm.list_voices("en_US")            # US English only
vm.get_voice("en_US-lessac-medium") # single voice info or None

The lang parameter accepts both 2-letter codes ("en") to match all regional variants and full locale strings ("en_US") for exact matching.

Install & Manage

vm.install("en_US-lessac-medium", progress_cb=None)
vm.uninstall("en_US-lessac-medium")  # -> True if removed
vm.is_installed("en_US-lessac-medium") # -> bool
vm.get_path("en_US-lessac-medium")   # -> Path or None

The progress_cb receives (filename, block_num, block_size, total_size) during download.

Resolve

# Find best installed voice for a language
path = vm.resolve(lang="en")

# Use a specific voice (auto-downloads if missing)
path = vm.resolve(voice="en_US-lessac-medium")

# Prefer exact locale, fall back to any match
path = vm.resolve(lang="en_US")

TTS Synthesis

# Synthesize to WAV file
wav_path = vm.synthesize("en_US-lessac-medium", "Hello!")
wav_path = vm.synthesize("en_US-lessac-medium", "Hello!", output_path="out.wav")

# Multiple texts with pauses
wav_path = vm.synthesize_multi("en_US-lessac-medium", ["Hello.", "World."], pause_ms=700)

# Synthesize and play immediately
vm.speak("en_US-lessac-medium", "Hello, world!")

# Volume control
vm.set_volume(75)

Voice Loading

# Load a PiperVoice instance for direct use
voice = vm.load_voice("en_US-lessac-medium")

Language Detection

# Detect language from system locale
lang = VoiceManager.detect_language()  # -> 'en_US' or 'pl_PL' etc.

Interactive TUI

# Basic usage — browse English voices
vm.browse(lang="en")

# With configuration
from voxkit import BrowserConfig

config = BrowserConfig(
    lang="pl",
    default_voice="pl_PL-darkman-medium",
    show_size=True,
    test_fn=lambda key: vm.speak(key, "Dzień dobry"),
    on_install=lambda v: print(f"Installed {v['key']}"),
)
vm.browse(config=config)

The TUI supports:

  • Arrow keys — navigate the voice list
  • Enter — test the selected voice (auto-installs if needed)
  • i — install the selected voice
  • u — uninstall the selected voice
  • q / Esc / Ctrl-C — quit

Keybindings are configurable via BrowserConfig.keybindings.

Built-in Progress Bar

VoxKit includes a ready-made terminal progress bar for downloads:

from voxkit.browser import progress_bar

vm.install("en_US-lessac-medium", progress_cb=progress_bar)

Data Types

from voxkit import VoiceInfo, BrowserConfig, ProgressCallback

VoiceInfo

Returned by list_voices() and get_voice() as a dict with keys: key, name, language, quality, region, speakers, size_mb, installed.

BrowserConfig

Field Type Default Description
lang str "en" Language to browse
default_voice str | None None Mark as default in the list
show_size bool True Show download size column
test_fn Callable | None None Custom test function (voice_key) -> None
on_install Callable | None None Hook called after install (voice_info) -> None
on_uninstall Callable | None None Hook called after uninstall (voice_info) -> None
keybindings dict see below Custom key mappings

Default keybindings:

{
    "install": "i",
    "uninstall": "u",
    "test": "\r",
    "quit": ("q", "\x03", "\x1b"),
}

Storage Layout

<data_dir>/
├── models/          # Downloaded .onnx voice models
│   ├── <voice>.onnx
│   └── <voice>.onnx.json
└── cache/
    └── voices.json  # Cached Piper catalog (auto-refreshed)

License

Copyright (c) 2026 Jakub T. Jankiewicz

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

See LICENSE for the full text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

voxkit-0.1.1.tar.gz (32.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

voxkit-0.1.1-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file voxkit-0.1.1.tar.gz.

File metadata

  • Download URL: voxkit-0.1.1.tar.gz
  • Upload date:
  • Size: 32.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for voxkit-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2ce9b885d4fef2139896012c92597c9c9e303803c53381e1f808c3bfe81e8956
MD5 811b623d602574a1a5dfbdddcb7eb749
BLAKE2b-256 dc2cde9c07019a33fa05decfbecf341b2648bbe537c3e3e7fdb413837b3ea0a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for voxkit-0.1.1.tar.gz:

Publisher: publish.yml on jcubic/voxkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file voxkit-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: voxkit-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 27.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for voxkit-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f4918c63eb800d07489ddca8a8a42872195f9aa55666fa206831f6f07d574c07
MD5 44d695ceaa836a94469eb2fe3d1e0cca
BLAKE2b-256 e13ed043ce6644199bdd09fc4877badd1b9e88b99ed6879ad557495f28483db4

See more details on using hashes here.

Provenance

The following attestation bundles were made for voxkit-0.1.1-py3-none-any.whl:

Publisher: publish.yml on jcubic/voxkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page