Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Server configuration
HOST=localhost
PORT=7000

# SSL configuration
VERIFY_SSL=true

# Proxy configuration
USE_PROXY=true
PROXY_API_URL=https://proxy.scdn.io/api/get_proxy.php
PROXY_PROTOCOL=http
PROXY_BATCH_SIZE=5

# Queue configuration
MAX_QUEUE_SIZE=100
55 changes: 55 additions & 0 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Docker Build and Push

on:
release:
types: [published]

jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/ttsfm
tags: |
type=ref,event=tag
type=raw,value=latest
labels: |
org.opencontainers.image.source=${{ github.repositoryUrl }}

- name: Build and push
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Show image info
run: |
echo "Pushed tags: ${{ steps.meta.outputs.tags }}"
echo "Image digest: ${{ steps.build-and-push.outputs.digest }}"
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Virtual Environment
venv/
env/
ENV/

# IDE
.idea/
.vscode/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db
26 changes: 18 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,25 @@ COPY requirements.txt .
# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application files
COPY server.py .
COPY index.html .
COPY index_zh.html .
COPY script.js .
COPY styles.css .
# Copy all application directories and files
COPY main.py .
COPY server/ server/
COPY proxy/ proxy/
COPY utils/ utils/
COPY static/ static/

# Set default environment variables
ENV HOST=0.0.0.0 \
PORT=7000 \
VERIFY_SSL=true \
USE_PROXY=true \
PROXY_API_URL=https://proxy.scdn.io/api/get_proxy.php \
PROXY_PROTOCOL=http \
PROXY_BATCH_SIZE=5 \
MAX_QUEUE_SIZE=100

# Expose port 7000
EXPOSE 7000

# Command to run the application with host set to 0.0.0.0
CMD ["python", "server.py", "--host", "0.0.0.0"]
# Command to run the application
CMD ["python", "main.py"]
152 changes: 98 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,134 @@
# TTSFM

[![Docker Image](https://img.shields.io/docker/pulls/dbcccc/ttsfm?style=flat-square)](https://hub.docker.com/r/dbcccc/ttsfm)
[![Docker Pulls](https://img.shields.io/docker/pulls/dbcccc/ttsfm?style=flat-square&logo=docker)](https://hub.docker.com/r/dbcccc/ttsfm)
[![License](https://img.shields.io/github/license/dbccccccc/ttsfm?style=flat-square)](LICENSE)
[![GitHub Stars](https://img.shields.io/github/stars/dbccccccc/ttsfm?style=social)](https://github.com/dbccccccc/ttsfm)

[English](README.md) | [中文](README_CN.md)
> ⚠️ **Disclaimer**
> This project is for learning and testing purposes only. For production environments, please use [OpenAI's official TTS service](https://platform.openai.com/docs/guides/audio).

TTSFM is a reverse-engineered API server that mirrors OpenAI's TTS service, providing a compatible interface for text-to-speech conversion with multiple voice options.
English | [中文](README_CN.md)

### Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- OR Docker
## 🌟 Project Introduction

### Installation
TTSFM is a reverse-engineered API server that is fully compatible with OpenAI's Text-to-Speech (TTS) interface.

#### Option 1: Using Docker (Recommended)
```bash
docker pull dbcccc/ttsfm:latest
docker run -p 7000:7000 dbcccc/ttsfm:latest
> 🎮 Try it now: [Official Demo Site](https://ttsapi.fm)

## 🏗️ Project Structure

```text
ttsfm/
├── main.py # Application entry
├── server/ # Core services
│ ├── api.py # OpenAI-compatible API
│ └── handlers.py # Request handlers
├── proxy/ # Proxy system
│ └── manager.py
├── utils/ # Utility modules
│ └── config.py
├── static/ # Frontend resources
│ ├── index.html # English interface
│ ├── index_zh.html # Chinese interface
│ └── ... # JS/CSS resources
└── requirements.txt # Python dependencies
```

#### Option 2: Manual Installation
1. Clone the repository:
## 🚀 Quick Start

### System Requirements
- Python ≥ 3.8
- Or Docker environment

### 🐳 Docker Run (Recommended)

Basic usage:
```bash
git clone https://github.com/yourusername/ttsfm.git
cd ttsfm
docker run -p 7000:7000 dbcccc/ttsfm:latest
```

2. Install dependencies:
Custom configuration using environment variables:
```bash
pip install -r requirements.txt
docker run -d \
-p 7000:7000 \
-e HOST=0.0.0.0 \
-e PORT=7000 \
-e VERIFY_SSL=true \
-e USE_PROXY=false \
-e PROXY_API_URL=https://proxy.scdn.io/api/get_proxy.php \
-e PROXY_PROTOCOL=http \
-e PROXY_BATCH_SIZE=5 \
-e MAX_QUEUE_SIZE=100 \
dbcccc/ttsfm:latest
```

### Usage
Available environment variables:
- `HOST`: Server host (default: 0.0.0.0)
- `PORT`: Server port (default: 7000)
- `VERIFY_SSL`: Whether to verify SSL certificates (default: true)
- `USE_PROXY`: Whether to use proxy pool (default: true)
- `PROXY_API_URL`: Proxy API URL (default: https://proxy.scdn.io/api/get_proxy.php)
- `PROXY_PROTOCOL`: Proxy protocol (default: http)
- `PROXY_BATCH_SIZE`: Number of proxies to fetch at once (default: 5)
- `MAX_QUEUE_SIZE`: Maximum number of tasks in queue (default: 100)

> 💡 **Tip**
> MacOS users experiencing port conflicts can use alternative ports:
> `docker run -p 5051:7000 dbcccc/ttsfm:latest`

#### Option 1: Using Docker
1. The server will start automatically after running the docker command
2. Access the web interface at `http://localhost:7000`
### 📦 Manual Installation

#### Option 2: Manual Usage
1. Start the server:
1. Download the latest release package from [GitHub Releases](https://github.com/dbccccccc/ttsfm/releases)
2. Extract and enter the directory:
```bash
python server.py
tar -zxvf ttsfm-vX.X.X.tar.gz
cd ttsfm-vX.X.X
```
3. Install dependencies and launch:
```bash
pip install -r requirements.txt
cp .env.example .env # Edit config as needed
python main.py
```

2. Access the web interface at `http://localhost:7000`
## 📚 Usage Guide

3. Use the API endpoint
### Web Interface
Access `http://localhost:7000` to experience the interactive demo

### API Endpoints
Please refer to the deployed webpage for detailed information.
- `POST /v1/audio/speech`: Convert text to speech
- `GET /v1/voices`: List available voices
| Endpoint | Method | Description |
|------|------|-------------|
| `/v1/audio/speech` | POST | Text-to-Speech |
| `/api/queue-size` | GET | Query task queue |

### Pressure Testing
The project includes a pressure test script to evaluate server performance under load. To use it:
> 🔍 Complete API documentation is available via the web interface after local deployment

### 🧪 Stress Testing
```bash
# Basic test (10 requests, 2 concurrent connections)
# Basic test
python pressure_test.py

# Test with more requests and higher concurrency
python pressure_test.py -n 50 -c 10
# Custom test example
python pressure_test.py -n 50 -c 10 -t long -s
```

# Test with different text lengths
python pressure_test.py -t short # Short text
python pressure_test.py -t medium # Medium text (default)
python pressure_test.py -t long # Long text
**Parameter Explanation**:
- `-n` Total requests
- `-c` Concurrency count
- `-t` Text length (short/medium/long)
- `-s` Save generated audio

# Save generated audio files
python pressure_test.py -s
## 🤝 Contributing

# Custom server URL
python pressure_test.py -u http://localhost:7000
```
We welcome all forms of contributions! You can participate by:

Options:
- `-n, --num-requests`: Total number of requests to send (default: 10)
- `-c, --concurrency`: Number of concurrent connections (default: 2)
- `-t, --text-length`: Length of text to use (short/medium/long)
- `-s, --save-audio`: Save generated audio files to test_output directory
- `-u, --url`: Custom server URL (default: http://localhost:7000)
- Submitting [Issues](https://github.com/dbccccccc/ttsfm/issues) to report problems
- Creating [Pull Requests](https://github.com/dbccccccc/ttsfm/pulls) to improve code
- Sharing usage experiences and suggestions

### License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
📜 Project licensed under [MIT License](LICENSE)

## Star History
## 📈 Project Activity

[![Star History Chart](https://api.star-history.com/svg?repos=dbccccccc/ttsfm&type=Date)](https://www.star-history.com/#dbccccccc/ttsfm&Date)
[![Star History Chart](https://api.star-history.com/svg?repos=dbccccccc/ttsfm&type=Date)](https://star-history.com/#dbccccccc/ttsfm&Date)
Loading