A TTS that fits in your CPU (and pocket)
Python
Now --voice defaults to alba with voice cloning on custom config (#248)
Gabriel de Marmiesse2b88c3787f27
diff --git a/README.md b/README.mdindex 70c71fe..47fdedf 100644--- a/README.md+++ b/README.md@@ -247,6 +247,8 @@ uvx pocket-tts generate --config https://raw.githubusercontent.com/kyutai-labs/pIt also works with huggingface urls like `hf://kyutai/pocket-tts/config/english_2026-04.yaml` or local paths like `./english_2026-04.yaml`.+The pre-made voices listed above are embeddings precomputed with our released weights, so they are not available for community models. With `--config`, `--voice` defaults to [alba's audio file](https://huggingface.co/kyutai/tts-voices/blob/main/alba-mackenna/casual.wav), which any model can clone. Pass your own audio file to `--voice` to use another voice.+We recommend inserting the commit hash somehow in the url to avoid breaking changes by the model authors. For example:```bashdiff --git a/docs/CLI Commands/generate.md b/docs/CLI Commands/generate.mdindex 8cd5769..c6d9286 100644--- a/docs/CLI Commands/generate.md+++ b/docs/CLI Commands/generate.md@@ -17,7 +17,7 @@ This will generate a WAV file `./tts_output.wav` with the default text and voice### Core Options- `--text TEXT`: Text to generate (default: "Hello world! I am Kyutai Pocket TTS. I'm fast enough to run on small CPUs. I hope you'll like me.")-- `--voice VOICE`: Path to audio conditioning file (voice to clone). Defaults to a built-in voice chosen from the language: `giovanni` (it) for italian, `lola` (es) for spanish, `juergen` (de) for german, `rafael` (pt) for portuguese, `estelle` (fr) for french, `alba` (en) otherwise. Urls and local paths are supported.+- `--voice VOICE`: Path to audio conditioning file (voice to clone). Defaults to a built-in voice chosen from the language: `giovanni` (it) for italian, `lola` (es) for spanish, `juergen` (de) for german, `rafael` (pt) for portuguese, `estelle` (fr) for french, `alba` (en) otherwise. With `--config` or `--checkpoint`, defaults to [alba's audio file](https://huggingface.co/kyutai/tts-voices/blob/main/alba-mackenna/casual.wav) instead of the voice name, since the pre-made voices only exist for the released language models. Urls and local paths are supported.- `--output-path OUTPUT_PATH`: Output path for generated audio (default: "./tts_output.wav")- `--language LANGUAGE`: Language for the TTS model, one of `'english_2026-01'`, `'english_2026-04'`, `'english'`, `'french_24l'`, `'german'`, `'german_24l'`, `'portuguese'`, `'portuguese_24l'`, `'italian'`, `'italian_24l'`, `'spanish'`, `'spanish_24l'` (default: `english`, which is the same model as `'english_2026-04'`). Incompatible with `--config`. The "24l" variants are bigger models, not distilled yet and here only as preview.diff --git a/pocket_tts/default_parameters.py b/pocket_tts/default_parameters.pyindex dad02e6..9b7d03a 100644--- a/pocket_tts/default_parameters.py+++ b/pocket_tts/default_parameters.py@@ -1,3 +1,5 @@+from pocket_tts.utils.utils import _ORIGINS_OF_PREDEFINED_VOICES+DEFAULT_LANGUAGE = "english"DEFAULT_TEMPERATURE = 0.7DEFAULT_SAMPLER_DECODE_STEPS = 1@@ -48,6 +50,10 @@ DEFAULT_VOICE_FOR_LANGUAGE = {"french": "estelle",}DEFAULT_VOICE_FALLBACK = "alba"+# Predefined voices are states precomputed with the released weights of a language model,+# so neither a custom config nor a training checkpoint can use them. For those we default+# to the audio file behind the fallback voice: any model can clone it.+DEFAULT_VOICE_FOR_CUSTOM_MODEL = _ORIGINS_OF_PREDEFINED_VOICES[DEFAULT_VOICE_FALLBACK]def get_default_text_for_language(language: str | None) -> str:@@ -57,7 +63,16 @@ def get_default_text_for_language(language: str | None) -> str:return DEFAULT_TEXT_FOR_LANGUAGE[DEFAULT_LANGUAGE]-def get_default_voice_for_language(language: str | None) -> str:+def get_default_voice_for_language(+ language: str | None, config: str | None = None, checkpoint: str | None = None+) -> str:+ """The voice to use when the user didn't pick one.++ `config` and `checkpoint` both mean custom weights, which cannot use the predefined+ voices, hence the audio file instead of the voice name.+ """+ if config is not None or checkpoint is not None:+ return DEFAULT_VOICE_FOR_CUSTOM_MODELfor key, voice in DEFAULT_VOICE_FOR_LANGUAGE.items():if language is not None and key in language:return voicediff --git a/pocket_tts/main.py b/pocket_tts/main.pyindex a781a40..3fef48e 100644--- a/pocket_tts/main.py+++ b/pocket_tts/main.py@@ -41,6 +41,8 @@ cli_app = typer.Typer(# Global model instancetts_model: TTSModel | None = None+# Voice served when a request doesn't specify one, resolved from the `serve` options.+default_voice: str | None = Noneweb_app = FastAPI(title="Kyutai Pocket TTS API", description="Text-to-Speech generation API", version="1.0.0"@@ -135,7 +137,7 @@ def text_to_speech(raise HTTPException(status_code=400, detail="Text cannot be empty")if voice_url is None and voice_wav is None:- voice_url = get_default_voice_for_language(str(tts_model.origin))+ voice_url = default_voiceif voice_url is not None and voice_wav is not None:raise HTTPException(status_code=400, detail="Cannot provide both voice_url and voice_wav")@@ -207,8 +209,9 @@ def serve():"""Start the FastAPI server."""- global tts_model+ global tts_model, default_voicetts_model = TTSModel.load_model(language=language, config=config, quantize=quantize)+ default_voice = get_default_voice_for_language(language, config)uvicorn.run("pocket_tts.main:web_app", host=host, port=port, reload=reload)@@ -228,7 +231,9 @@ def generate("Path to audio conditioning file (voice to clone). ""Defaults to a built-in voice chosen from the language: ""'giovanni' for italian, 'lola' for spanish, 'juergen' for german, "- "'rafael' for portuguese, 'estelle' for french, 'alba' otherwise."+ "'rafael' for portuguese, 'estelle' for french, 'alba' otherwise. "+ "With the config or checkpoint argument, defaults to alba's audio file, "+ "which any model can clone."),show_default=False,),@@ -317,7 +322,7 @@ def generate(tts_model.to(device)if voice is None:- voice = get_default_voice_for_language(language)+ voice = get_default_voice_for_language(language, config, checkpoint)model_state_for_voice = tts_model.get_state_for_audio_prompt(voice)# Stream audio generation directly to file or stdoutaudio_chunks = tts_model.generate_audio_stream(