Add FastAPI server for OpenAI-compatible API #280
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a simple, OpenAI-compatible API server using FastAPI. It exposes the TTS functionality over HTTP endpoints, including /v1/audio/speech for easy integration with tools like Open WebUI.
Why is this change needed?
This makes it much easier to use MeloTTS as a backend service in other applications without needing to write custom Python scripts.
How was it tested?
The API was tested in a clean conda environment. All necessary dependencies were discovered and added to a requirements.txt file to ensure a smooth installation process. using Ubuntu 20.04 / Linux Mint 20 OS.
I see there is another excellent PR (#56) that also adds an API. This implementation is different, as it's designed to be run standalone without Docker, making it more accessible for users who may not be familiar with containerization.
A significant part of this contribution is also the tested requirements.txt file, which solves over a dozen missing dependencies from the base pip package and allows for a clean one-step installation. The documentation has also been written with a full, step-by-step guide for getting started and connecting to Open WebUI.