tts-api / README.md
Divax
test
687d738
---
title: XTTS C3PO Voice Cloning API
emoji: πŸ€–
colorFrom: indigo
colorTo: yellow
sdk: docker
pinned: false
---
# πŸ€– C-3PO TTS API
A FastAPI-based text-to-speech service using the **C-3PO fine-tuned XTTS v2 model** from [Borcherding/XTTS-v2_C3PO](https://huggingface.co/Borcherding/XTTS-v2_C3PO) for authentic C-3PO voice synthesis.
## ✨ Features
- πŸ€– **Authentic C-3PO Voice**: Fine-tuned XTTS v2 model with 20 unique C-3PO voice lines
- 🌍 **17+ Languages**: Multilingual support while maintaining C-3PO characteristics
- 🎭 **Voice Cloning**: Optional custom voice cloning capabilities
- πŸš€ **FastAPI**: Modern API with automatic documentation
- 🐳 **Docker Ready**: Containerized for easy deployment
## πŸš€ Quick Start
### Docker Deployment
```bash
# Build the container
docker build -t c3po-tts .
# Run the container
docker run -p 7860:7860 c3po-tts
```
### Local Development
```bash
# Install dependencies
pip install -r requirements.txt
# Run the API
python coqui_api.py
```
The API will be available at `http://localhost:7860`
## πŸ“‘ API Endpoints
### C-3PO Text-to-Speech
```bash
curl -X POST "http://localhost:7860/tts-c3po" \
-F "text=I am C-3PO, human-cyborg relations." \
-F "language=en" \
--output c3po_voice.wav
```
### General Text-to-Speech (with C-3PO voice by default)
```bash
curl -X POST "http://localhost:7860/tts" \
-F "text=The odds of successfully navigating an asteroid field are approximately 3,720 to 1." \
-F "language=en" \
--output c3po_output.wav
```
### JSON API
```bash
curl -X POST "http://localhost:7860/tts-json" \
-H "Content-Type: application/json" \
-d '{"text": "R2-D2, you know better than to trust a strange computer!", "language": "en"}' \
--output c3po_json.wav
```
### Health Check
```bash
curl http://localhost:7860/health
```
## 🌍 Supported Languages
English, Spanish, French, German, Italian, Portuguese, Polish, Turkish, Russian, Dutch, Czech, Arabic, Chinese, Japanese, Hungarian, Korean, Hindi
## 🎨 Example C-3PO Phrases
Perfect texts for demonstrating C-3PO's voice:
- "I am C-3PO, human-cyborg relations."
- "The odds of successfully navigating an asteroid field are approximately 3,720 to 1."
- "R2-D2, you know better than to trust a strange computer!"
- "Oh my! How interesting!"
## πŸ“– API Documentation
Visit `http://localhost:7860/docs` for interactive API documentation.
## πŸ§ͺ Testing
```bash
# Run the C-3PO test suite
python test_c3po_model.py
```
## πŸ”§ Configuration
The API automatically downloads the C-3PO model on first run. Environment variables:
- `COQUI_TOS_AGREED=1`: Accepts Coqui TTS terms
- `HF_HUB_DISABLE_TELEMETRY=1`: Disables telemetry
## πŸ“¦ Files
- `coqui_api.py`: Main C-3PO TTS API
- `test_c3po_model.py`: Test suite for C-3PO functionality
- `start_c3po_api.py`: Startup script with dependency checks
- `Dockerfile`: Container configuration
- `requirements.txt`: Python dependencies
## 🎭 Credits
- [C-3PO Fine-tuned Model](https://huggingface.co/Borcherding/XTTS-v2_C3PO) by Borcherding
- [Coqui TTS](https://github.com/coqui-ai/TTS) - The underlying TTS engine
- [FastAPI](https://fastapi.tiangolo.com/) - Web framework