AudiobookGen is a local-first text-to-speech service that wraps the KaniTTS model in a web UI and REST API. The project supports two operational modes:
- Automatic mode – one click to process the entire input using the default voice and parameters.
- Manual mode – advanced operators can inspect detected text chunks and synthesise them one-by-one, optionally using different voices per segment.
The repository is structured so that the heavy KaniTTS dependency tree is optional. By default a lightweight mock engine generates placeholder audio which keeps the project runnable in constrained environments while preserving the control flow. Deployments that require real speech can install the official KaniTTS model (see below) and the service will use it automatically.
- Multi-voice selection based on the KaniTTS presets
- Text box and file upload input methods
- Automatic chunking for long texts
- REST endpoint for programmatic integrations (
POST /api/synthesize) - Manual segmentation workflow with per-chunk downloads
- Python 3.10+
- (Optional for real speech) CUDA-capable GPU with ~2 GB VRAM and the
transformers,torch, andnemo_toolkitpackages installed
Install dependencies:
pip install -r requirements.txtpython -m app.serverThe service exposes an interactive UI at http://localhost:8000 and the JSON
API at http://localhost:8000/api/synthesize.
Example request using curl:
curl -X POST http://localhost:8000/api/synthesize \
-H "Content-Type: application/json" \
-d '{
"text": "Once upon a midnight dreary...",
"voice": "Jenny (English, Irish)",
"temperature": 1.2
}'Response:
{
"audio_file": "outputs/audiobook_20240101_120000.wav",
"duration_seconds": 18.4,
"segments": [0, 1, 2],
"voice": "Jenny (English, Irish)"
}The path refers to a WAV file stored inside the outputs/ directory.
Install the additional dependencies:
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install transformers nemo_toolkit[tts] librosaWhen these packages are available the service automatically loads the official KaniTTS weights during startup. Otherwise, it falls back to the deterministic mock engine to keep the workflow testable.
- Static files live in
static/, templates intemplates/, and the business logic in theaudiobookgen/package. - Outputs are stored in the
outputs/directory by default. - Run
python -m compileall .to ensure there are no syntax errors.
MIT