Metadata-Version: 2.5
Name: fastrtc-pocket-tts
Version: 0.1.2
Summary: A FastRTC-compatible TTS wrapper for Kyutai's ultra-low latency Pocket TTS.
Project-URL: Homepage, https://github.com/rohanprichard/fastrtc-pocket-tts
Project-URL: Author, https://rohanprichard.com
Author-email: Rohan Richard <rohanrichard.work@gmail.com>
License: MIT
License-File: LICENSE
Keywords: audio,fastrtc,gradio,huggingface,kyutai,pocket-tts,tts,webrtc,websocket
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: fastrtc[vad]>=0.0.34
Requires-Dist: numpy
Requires-Dist: pocket-tts>=1.1.0
Description-Content-Type: text/markdown

# fastrtc-pocket-tts
[![PyPI Downloads](https://static.pepy.tech/personalized-badge/fastrtc-pocket-tts?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/fastrtc-pocket-tts)

A FastRTC-compatible Text-to-Speech (TTS) adapter for Kyutai's ultra-low latency Pocket TTS.

Pocket TTS is a highly optimized, CPU-bound model that requires no GPU and generates speech up to 6x faster than real-time (~200ms time-to-first-audio). 

Features
- ⚡ Ultra-Low Latency: ~200ms to the first audio chunk.
- 💻 CPU-based: Runs effortlessly on Mac, Windows, and Linux without CUDA/Metal dependencies.
- 🧵 Non-Blocking: Implements threaded async generation to keep your WebRTC/FastAPI event loops responsive.
- 🗣️ Instant Voice Cloning: Supply a .wav file, and it clones the voice instantly.


## Installation
Install via pip:
```bash
pip install fastrtc-pocket-tts
```

This package requires Python 3.10+ and automatically installs fastrtc and pocket-tts as dependencies.


## Quickstart
Run a local conversational AI that responds to you in real-time using your computer's microphone.

```python
from fastrtc import Stream, ReplyOnPause
from fastrtc_pocket_tts import PocketTTS, PocketVoice

# Initialize the model using a built-in voice
tts_engine = PocketTTS(default_voice=PocketVoice.ALBA)

def voice_handler(audio):
    # In a real app, you would pass `audio` to an STT and LLM here.
    # For this example, we'll just respond with static text.
    response_text = "I am speaking to you directly from your CPU."
    
    # Yield the audio stream chunks back to FastRTC
    for chunk in tts_engine.stream_tts_sync(response_text):
        yield chunk

# Mount it on a FastRTC stream
stream = Stream(ReplyOnPause(voice_handler), modality="audio", mode="send-receive")

# Launch the interactive WebRTC UI
stream.ui.launch()
```

## Voice Cloning
Pocket TTS allows zero-shot voice cloning. Simply provide a valid path to a local audio file (.wav, .mp3) when initializing the model or passing options.

```python
from fastrtc_pocket_tts import PocketTTS

# The model will automatically extract the voice embedding from the audio file
tts_engine = PocketTTS(default_voice="./path/to/my_voice_sample.wav")


Available Built-In Voices
If you don't want to use voice cloning, Kyutai provides 8 pre-trained English default voices:
alba, marius, javert, jean, fantine, cosette, eponine, azelma.
You can access them safely using the PocketVoice Enum:
from fastrtc_pocket_tts import PocketVoice

voice = PocketVoice.JAVERT
```

## License
MIT License.
