https://github.com/parisneo/parler-tts-fastapi
https://github.com/parisneo/parler-tts-fastapi
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/parisneo/parler-tts-fastapi
- Owner: ParisNeo
- License: apache-2.0
- Created: 2024-08-28T23:21:05.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-29T09:54:20.000Z (almost 2 years ago)
- Last Synced: 2025-06-06T00:41:40.329Z (about 1 year ago)
- Language: Python
- Size: 36.1 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Parler-TTS-FastAPI




[](https://github.com/ParisNeo/parler-tts-fastapi/issues)
[](https://github.com/ParisNeo/parler-tts-fastapi/stargazers)
## Project Overview
- **Author**: ParisNeo (Research Engineer)
- **Version**: 1.1
- **Description**: This project implements a FastAPI-based web service for the Parler-TTS (Text-to-Speech) model. It provides endpoints for generating speech from text input, supporting both single-request and streaming responses. The API can output audio in base64 encoded format or as WAV files.
## Key Features
- Text-to-speech generation with customizable voice descriptions
- Streaming capability for processing longer texts
- Support for base64 and WAV output formats
- GPU acceleration support
- Sentence-by-sentence processing for streaming responses
- FastAPI server with automatic Swagger UI documentation
## Requirements
- Python 3.7+
- FastAPI
- Uvicorn
- PyTorch
- Parler-TTS
- Transformers
- SoundFile
- Pydantic
- NLTK
## Installation
1. Install PyTorch with CUDA support (if available):
```
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 --upgrade
```
2. Install the required dependencies:
```
pip install -r requirements.txt
```
## Usage
1. Start the server:
```
python parler_tts_server.py [--host HOST] [--port PORT] [--use-gpu]
```
Options:
- `--host`: Host to run the server on (default: 0.0.0.0)
- `--port`: Port to run the server on (default: 8593)
- `--use-gpu`: Use GPU for inference if available
2. The server will start running on the specified host and port (default: `http://0.0.0.0:8593`).
3. Access the API documentation at `http://:/docs`.
## API Endpoints
### POST /generate_speech
Generates speech from the given text and voice description.
**Request Body:**
```json
{
"text": "Hello, how are you?",
"voice_description": "A friendly, warm female voice",
"output_format": "base64"
}
```
**Response:**
- Base64 encoded WAV file or WAV file directly, depending on the specified output format.
### POST /generate_speech_stream
Streams generated speech for longer texts, processing sentence by sentence.
**Request Body:**
Same as `/generate_speech`
**Response:**
- Streaming response with audio data in the specified format.
### GET /
Returns a welcome message.
## Error Handling
The server includes error handling. If an error occurs during speech generation, it will return a 500 Internal Server Error with details about the error.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the Apache 2.0 License.
## Acknowledgements
This project uses the Parler-TTS model. Please refer to the [Parler-TTS repository](https://github.com/parler-tts/parler-tts) for more information about the model and its license.