Skip to content

Commit e0d26f6

Browse files
committed
production setup
1 parent 498842e commit e0d26f6

File tree

7 files changed

+328
-324
lines changed

7 files changed

+328
-324
lines changed

.env

Lines changed: 0 additions & 6 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ WORKDIR /app
1414
COPY requirements.txt .
1515

1616
# Install dependencies
17-
RUN pip install --no-cache-dir -r requirements.txt
17+
RUN pip install --no-cache-dir -r requirements.txt waitress
1818

1919
# Copy application files
2020
COPY . .

README.md

Lines changed: 81 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -48,110 +48,122 @@ ttsfm/
4848
## 🚀 Quick Start
4949

5050
### System Requirements
51-
- Docker and Docker Compose
52-
- or Python ≥ 3.8 with Redis
51+
- Python 3.13 or higher
52+
- Redis server
53+
- Docker (optional)
5354

54-
### 🐳 Docker Run (Recommended)
55-
56-
Basic usage:
55+
### Using Docker (Recommended)
5756
```bash
58-
docker run -p 7000:7000 -p 6379:6379 dbcccc/ttsfm:latest
59-
```
57+
# Pull the latest image
58+
docker pull dbcccc/ttsfm:latest
6059

61-
Custom configuration with environment variables:
62-
```bash
60+
# Run the container
6361
docker run -d \
62+
--name ttsfm \
6463
-p 7000:7000 \
6564
-p 6379:6379 \
66-
-e HOST=0.0.0.0 \
67-
-e PORT=7000 \
68-
-e VERIFY_SSL=true \
69-
-e MAX_QUEUE_SIZE=100 \
70-
-e RATE_LIMIT_REQUESTS=30 \
71-
-e RATE_LIMIT_WINDOW=60 \
72-
-e CELERY_BROKER_URL=redis://localhost:6379/0 \
73-
-e CELERY_RESULT_BACKEND=redis://localhost:6379/0 \
65+
-v $(pwd)/voices:/app/voices \
7466
dbcccc/ttsfm:latest
7567
```
7668

77-
Available environment variables:
78-
- `HOST`: Server host (default: 0.0.0.0)
79-
- `PORT`: Server port (default: 7000)
80-
- `VERIFY_SSL`: Verify SSL certificates (default: true)
81-
- `MAX_QUEUE_SIZE`: Maximum queue size (default: 100)
82-
- `RATE_LIMIT_REQUESTS`: Maximum requests per time window (default: 30)
83-
- `RATE_LIMIT_WINDOW`: Rate limit time window in seconds (default: 60)
84-
- `CELERY_BROKER_URL`: Redis broker URL (default: redis://localhost:6379/0)
85-
- `CELERY_RESULT_BACKEND`: Redis result backend URL (default: redis://localhost:6379/0)
86-
87-
### 📦 Manual Installation
88-
69+
### Manual Installation
8970
1. Clone the repository:
9071
```bash
9172
git clone https://github.com/dbccccccc/ttsfm.git
9273
cd ttsfm
9374
```
9475

95-
2. Install dependencies and start:
76+
2. Install dependencies:
9677
```bash
97-
cd flask_app
9878
pip install -r requirements.txt
79+
```
9980

100-
# Start Redis server
81+
3. Start Redis server:
82+
```bash
83+
# On Windows
10184
redis-server
10285

103-
# In a new terminal, start Celery worker
86+
# On Linux/macOS
87+
sudo service redis-server start
88+
```
89+
90+
4. Start Celery worker:
91+
```bash
10492
celery -A celery_worker.celery worker --pool=solo -l info
93+
```
10594

106-
# In another terminal, start Flask application
95+
5. Start the server:
96+
```bash
97+
# Development (not recommended for production)
10798
python app.py
108-
```
10999

110-
## 📚 Usage Guide
100+
# Production (recommended)
101+
waitress-serve --host=0.0.0.0 --port=7000 app:app
102+
```
111103

112-
### Web Interface
113-
Visit `http://localhost:7000` for the interactive demo
104+
### Environment Variables
105+
Copy `.env.example` to `.env` and modify as needed:
106+
```bash
107+
cp .env.example .env
108+
```
114109

115-
### API Endpoints
116-
| Endpoint | Method | Description |
117-
|----------|--------|-------------|
118-
| `/v1/audio/speech` | POST | Text to Speech |
119-
| `/api/queue-size` | GET | Query task queue |
120-
| `/api/voice-sample/<voice>` | GET | Get voice sample |
121-
| `/api/version` | GET | Get API version |
110+
## 🔧 Configuration
122111

123-
> 🔍 Complete API documentation is available in the web interface after local deployment
112+
### Server Configuration
113+
- `HOST`: Server host (default: 0.0.0.0)
114+
- `PORT`: Server port (default: 7000)
115+
- `VERIFY_SSL`: SSL verification (default: true)
116+
- `MAX_QUEUE_SIZE`: Maximum queue size (default: 100)
117+
- `RATE_LIMIT_REQUESTS`: Rate limit requests per window (default: 30)
118+
- `RATE_LIMIT_WINDOW`: Rate limit window in seconds (default: 60)
124119

125-
## 🔧 Architecture
120+
### Celery Configuration
121+
- `CELERY_BROKER_URL`: Redis broker URL (default: redis://localhost:6379/0)
122+
- `CELERY_RESULT_BACKEND`: Redis result backend URL (default: redis://localhost:6379/0)
126123

127-
The application uses a distributed task queue architecture:
124+
## 📚 API Documentation
128125

129-
1. **Flask Application**: Handles HTTP requests and serves the web interface
130-
2. **Celery**: Manages asynchronous task processing
131-
3. **Redis**: Acts as message broker and result backend
132-
4. **Task Queue**: Processes TTS requests asynchronously
126+
### Text-to-Speech
127+
```http
128+
POST /v1/audio/speech
129+
```
133130

134-
```mermaid
135-
graph TD
136-
A[Client] -->|HTTP Request| B[Flask App]
137-
B -->|Task| C[Celery]
138-
C -->|Queue| D[Redis]
139-
D -->|Process| E[Celery Worker]
140-
E -->|Result| D
141-
D -->|Response| B
142-
B -->|HTTP Response| A
131+
Request body:
132+
```json
133+
{
134+
"input": "Hello, world!",
135+
"voice": "alloy",
136+
"response_format": "mp3"
137+
}
143138
```
144139

145-
## 🤝 Contributing
140+
### Queue Status
141+
```http
142+
GET /api/queue-size
143+
```
146144

147-
We welcome all forms of contributions! You can participate by:
145+
### Voice Samples
146+
```http
147+
GET /api/voice-sample/{voice}
148+
```
148149

149-
- Submitting [Issues](https://github.com/dbccccccc/ttsfm/issues) to report problems
150-
- Creating [Pull Requests](https://github.com/dbccccccc/ttsfm/pulls) to improve code
151-
- Sharing usage experiences and suggestions
150+
### Version
151+
```http
152+
GET /api/version
153+
```
152154

153-
📜 Project licensed under [MIT License](LICENSE)
155+
## 🧪 Testing
156+
Run the test suite:
157+
```bash
158+
python test_api.py
159+
python test_queue.py
160+
```
154161

155-
## 📈 Project Activity
162+
## 📝 License
163+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
156164

157-
[![Star History Chart](https://api.star-history.com/svg?repos=dbccccccc/ttsfm&type=Date)](https://star-history.com/#dbccccccc/ttsfm&Date)
165+
## 🙏 Acknowledgments
166+
- [OpenAI](https://openai.com/) for the TTS API format
167+
- [Flask](https://flask.palletsprojects.com/) for the web framework
168+
- [Celery](https://docs.celeryq.dev/) for task queue management
169+
- [Waitress](https://docs.pylonsproject.org/projects/waitress/) for the production WSGI server

0 commit comments

Comments
 (0)