This is a WebSocket API implementation for F5-TTS that allows other programs to access TTS services through a WebSocket interface.
- Windows: Fully tested and supported
- Linux: Not fully tested, may require modifications to scripts and paths
- macOS: Not tested
Flash Attention 2 integration is currently under development and not functional. This feature will be added in future updates to improve performance.
# Run the Windows installation script
setup.batThis script will:
- Set up the required environment
- Install dependencies
- Configure the project for API usage
# Launch the WebSocket API server
tts-api.batThe server will start on ws://localhost:8000 by default.
# Run the test script
test_api.batIf you want to run this on Linux, you'll need to:
- Convert the
.batscripts to.shscripts - Modify file paths to use forward slashes
- Adjust environment setup commands
- Test the WebSocket implementation in your environment
We welcome contributions to improve Linux support!
{
"type": "tts_request",
"data": {
"text": "Text to synthesize",
"reference_audio": "base64_encoded_audio",
"config": {
// Optional configuration parameters
}
}
}{
"type": "tts_response",
"data": {
"audio": "base64_encoded_audio",
"status": "success",
"message": "Optional status message"
}
}The system uses TOML files for configuration. Here's an example structure:
# Model selection
model = "F5TTS_Base"
# Audio input/output settings
ref_audio = "reference/reference.wav"
ref_text = "Reference text for the audio"
gen_text = "Text to be generated"
# Optional settings
remove_silence = false
output_dir = "tests"
output_file = "output.wav"F5-TTS/
├── api/ # WebSocket API implementation
├── tests/ # Test files and output directory
├── reference/ # Reference audio files
├── setup.bat # Windows installation script
├── test_api.bat # Windows API testing script
├── tts-api.bat # Windows server startup script
└── custom.toml # Configuration file
api/: Contains the WebSocket server implementationtests/: Used for storing test outputs and test scriptsreference/: Stores reference audio files for TTS generation
The API includes robust error handling for common scenarios:
- Invalid audio format
- Missing configuration
- Server connection issues
- Processing errors
Feel free to contribute to this project by:
- Forking the repository
- Creating a feature branch
- Submitting a pull request
We especially welcome contributions for:
- Linux support improvements
- macOS compatibility
- Cross-platform testing
This project is licensed under the MIT License.