--- 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