To add a new TTS model to the framework, create a new directory under models/ with three files.
mkdir models/mymodel
cd models/mymodel{
"name": "My Model",
"voice_presets": ["voice1", "voice2"],
"emotion_tags": ["<laugh>", "<sigh>"],
"supports_description": false,
"supports_reference_audio": true
}| Field | Type | Description |
|---|---|---|
name |
string | Display name shown in the TUI |
voice_presets |
string[] | Available voice names (empty if not supported) |
emotion_tags |
string[] | Tags users can embed in text (empty if not supported) |
supports_description |
bool | Whether the model accepts a voice description string |
supports_reference_audio |
bool | Whether the model can clone from a reference WAV |
[project]
name = "tts-compare-mymodel"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"torch",
"soundfile",
"mymodel-package",
]The wrapper must:
- Read JSON from stdin
- Load the model and generate audio
- Write a WAV file to the specified output path
- Print timing data to stderr
- Print the output file path to stdout
#!/usr/bin/env python3
import json
import sys
import time
import numpy as np
import soundfile as sf
def generate(text: str, output_path: str) -> str:
t_load = time.perf_counter()
print("Loading model...", file=sys.stderr)
# model = load_your_model()
load_ms = (time.perf_counter() - t_load) * 1000
t_infer = time.perf_counter()
print("Generating speech...", file=sys.stderr)
# audio, sr = run_inference(model, text)
infer_ms = (time.perf_counter() - t_infer) * 1000
audio = np.clip(audio, -1.0, 1.0)
audio = (audio * 32767).astype(np.int16)
sf.write(output_path, audio, sr)
print(
f"TIMING:{json.dumps({'model_load_ms': round(load_ms, 1), 'model_inference_ms': round(infer_ms, 1)})}",
file=sys.stderr,
)
print("Done.", file=sys.stderr)
return output_path
if __name__ == "__main__":
params = json.loads(sys.stdin.read())
path = generate(
text=params["text"],
output_path=params["output_path"],
)
print(path)cd models/mymodel
uv sync # Creates isolated .venv
# Test directly
echo '{"text": "Hello", "output_path": "test.wav"}' | uv run python app.pyThe model will automatically appear in the TUI on the next run of python main.py.