File size: 3,190 Bytes
687d738
 
 
 
 
 
 
 
 
94fd4b0
c53fcc3
94fd4b0
9a88d9c
94fd4b0
9a88d9c
94fd4b0
 
 
 
 
9a88d9c
94fd4b0
5efbc82
94fd4b0
9acb9c3
94fd4b0
 
9acb9c3
94fd4b0
 
9a88d9c
 
94fd4b0
6a83fff
94fd4b0
6a83fff
 
94fd4b0
 
6a83fff
 
94fd4b0
6a83fff
94fd4b0
9a88d9c
94fd4b0
9a88d9c
94fd4b0
 
 
 
9acb9c3
 
94fd4b0
a7aae29
94fd4b0
 
 
 
a7aae29
 
94fd4b0
a7aae29
94fd4b0
 
 
 
a7aae29
9acb9c3
94fd4b0
9acb9c3
94fd4b0
9a88d9c
 
94fd4b0
9a88d9c
94fd4b0
9a88d9c
94fd4b0
a7aae29
94fd4b0
9a88d9c
94fd4b0
 
 
 
9acb9c3
94fd4b0
9a88d9c
94fd4b0
9acb9c3
94fd4b0
9acb9c3
 
94fd4b0
 
5efbc82
 
94fd4b0
a7aae29
94fd4b0
6a83fff
94fd4b0
 
a7aae29
94fd4b0
5efbc82
94fd4b0
 
 
 
 
5efbc82
94fd4b0
5efbc82
94fd4b0
 
 
5efbc82
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
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