Files
spark-pocket-tts/docs/pocket-tts-example.ipynb
T
Václav Volhejn 6f9dd250c2 Add Colab example (#67)
Thank you @HarishDevLab for the suggestion, I just reimplemented the PR
to link to a version-controlled notebook.
2026-01-19 10:29:53 +00:00

2.0 KiB

In [ ]:
# Locally, we recommend using `uv` over `pip`
!pip install pocket-tts
In [ ]:
import scipy.io.wavfile
from IPython.display import Audio

from pocket_tts import TTSModel

# The pre-defined voices are alba, marius, javert, jean, fantine, cosette, eponine, and azelma.
# You can also clone any voice you'd like by passing a file path!
# For voice cloning, please go to https://huggingface.co/kyutai/pocket-tts
# and accept the terms, then make sure you're logged in locally with `uvx hf auth login`.
voice = "alba"

tts_model = TTSModel.load_model()
voice_state = tts_model.get_state_for_audio_prompt(voice)

# Audio is a 1D torch tensor containing PCM data
audio = tts_model.generate_audio(voice_state, "Hello world, this is a test.")

# You can also find the output in the files tab on the left
scipy.io.wavfile.write("output.wav", tts_model.sample_rate, audio.numpy())

Audio(audio.numpy(), rate=tts_model.sample_rate)
In [ ]: