A TTS that fits in your CPU (and pocket)
Python
Change voices available without voice cloning (#12)
Gabriel de Marmiesse366aa68c23ea
diff --git a/README.md b/README.mdindex 448b613..8f80344 100644--- a/README.md+++ b/README.md@@ -1,6 +1,6 @@# Pocket TTS-+A lightweight text-to-speech (TTS) application designed to run efficiently on CPUs.Forget about the hassle of using GPUs and web APIs serving TTS models. With Kyutai's Pocket TTS, generating audio is just a pip install and a function call away.@@ -43,12 +43,23 @@ uvx pocket-tts generate# or if you installed it manually with pip:pocket-tts generate```-Modify the voice with `--voice` and the text with `--text`. We provide a small catalog of voices:-```-"marius", "javert", "jean", "fantine", "cosette", "eponine", "azelma"-```+Modify the voice with `--voice` and the text with `--text`. We provide a small catalog of voices.++You can take a look at [this page](https://huggingface.co/kyutai/tts-voices) which details the licenses+for each voice.++* [alba](https://huggingface.co/kyutai/tts-voices/blob/main/alba-mackenna/casual.wav)+* [marius](https://huggingface.co/kyutai/tts-voices/blob/main/voice-donations/Selfie.wav)+* [javert](https://huggingface.co/kyutai/tts-voices/blob/main/voice-donations/Butter.wav)+* [jean](https://huggingface.co/kyutai/tts-voices/blob/main/ears/p010/freeform_speech_01.wav)+* [fantine](https://huggingface.co/kyutai/tts-voices/blob/main/vctk/p244_023.wav)+* [cosette](https://huggingface.co/kyutai/tts-voices/blob/main/expresso/ex04-ex02_confused_001_channel1_499s.wav)+* [eponine](https://huggingface.co/kyutai/tts-voices/blob/main/vctk/p262_023.wav)+* [azelma](https://huggingface.co/kyutai/tts-voices/blob/main/vctk/p303_023.wav)+The `--voice` argument can also take a plain wav file as input for voice cloning.Feel free to check out the [generate documentation](https://github.com/kyutai-labs/pocket-tts/tree/main/docs/generate.md) for more details and examples.+For trying multiple voices and prompts quickly, prefer using the `serve` command.### The `serve` commanddiff --git a/pocket_tts/default_parameters.py b/pocket_tts/default_parameters.pyindex 4d1e6cd..390b817 100644--- a/pocket_tts/default_parameters.py+++ b/pocket_tts/default_parameters.py@@ -1,4 +1,4 @@-DEFAULT_AUDIO_PROMPT = "marius"+DEFAULT_AUDIO_PROMPT = "alba"DEFAULT_VARIANT = "b6369a24"DEFAULT_TEMPERATURE = 0.7DEFAULT_LSD_DECODE_STEPS = 1diff --git a/pocket_tts/main.py b/pocket_tts/main.pyindex 2d2c16f..6dba5be 100644--- a/pocket_tts/main.py+++ b/pocket_tts/main.py@@ -248,6 +248,9 @@ def generate(# Only print the result message if not writing to stdoutif output_path != "-":logger.info("Results written in %s", output_path)+ logger.info(+ "If you want to try multiple voices and prompts quickly, try the `serve` command."+ )if __name__ == "__main__":diff --git a/pocket_tts/models/tts_model.py b/pocket_tts/models/tts_model.pyindex cae6383..7ef44e9 100644--- a/pocket_tts/models/tts_model.py+++ b/pocket_tts/models/tts_model.py@@ -620,7 +620,10 @@ class TTSModel(nn.Module):with display_execution_time("Encoding audio prompt"):prompt = self._encode_audio(audio_conditioning.unsqueeze(0).to(self.device))# import safetensors.torch- # safetensors.torch.save_file({"audio_prompt": prompt}, "embeddings/eponine.safetensors")+ # safetensors.torch.save_file(+ # {"audio_prompt": prompt},+ # "/projects/huggingface/pocket-tts/embeddings/cosette.safetensors"+ # )model_state = init_states(self.flow_lm, batch_size=1, sequence_length=1000)diff --git a/pocket_tts/utils/utils.py b/pocket_tts/utils/utils.pyindex d6e32ab..9f2dd8d 100644--- a/pocket_tts/utils/utils.py+++ b/pocket_tts/utils/utils.py@@ -11,14 +11,11 @@ from torch import nnPROJECT_ROOT = Path(__file__).parent.parent.parent+_voices_names = ["alba", "marius", "javert", "jean", "fantine", "cosette", "eponine", "azelma"]PREDEFINED_VOICES = {- "marius": "hf://kyutai/pocket-tts-without-voice-cloning/embeddings/marius.safetensors",- "javert": "hf://kyutai/pocket-tts-without-voice-cloning/embeddings/javert.safetensors",- "jean": "hf://kyutai/pocket-tts-without-voice-cloning/embeddings/jean.safetensors",- "fantine": "hf://kyutai/pocket-tts-without-voice-cloning/embeddings/fantine.safetensors",- "cosette": "hf://kyutai/pocket-tts-without-voice-cloning/embeddings/cosette.safetensors",- "eponine": "hf://kyutai/pocket-tts-without-voice-cloning/embeddings/eponine.safetensors",- "azelma": "hf://kyutai/pocket-tts-without-voice-cloning/embeddings/azelma.safetensors",+ # don't forget to change this+ x: f"hf://kyutai/pocket-tts-without-voice-cloning/embeddings/{x}.safetensors"+ for x in _voices_names}