REST API for Whisper-WebUI. Documentation is auto-generated upon deploying the app.
Swagger UI is available at app/docs
or root URL with redirection. Redoc is available at app/redoc
.
Installation assumes that you are in the root directory of Whisper-WebUI
- Create
.env
inbackend/configs/.env
HF_TOKEN="YOUR_HF_TOKEN FOR DIARIZATION MODEL (READ PERMISSION)"
DB_URL="sqlite:///backend/records.db"
HF_TOKEN
is used to download diarization model, DB_URL
indicates where your db file is located. It is stored in backend/
by default.
- Install dependency
pip install -r backend/requirements-backend.txt
- Deploy the server with
uvicorn
or whatever.
uvicorn backend.main:app --host 0.0.0.0 --port 8000
You can deploy the server with your domain name by setting up a reverse proxy with Nginx.
- Install Nginx if you don't already have it.
- Linux : https://nginx.org/en/docs/install.html
- Windows : https://nginx.org/en/docs/windows.html
-
Edit
nginx.conf
for your domain name.Whisper-WebUI/backend/nginx/nginx.conf
Line 12 in 895cafe
-
Add an A type record of your public IPv4 address in your domain provider. (you can get it by searching "What is my IP" in Google)
-
Open a terminal and go to the location of
nginx.conf
, then start the nginx server, so that you can manage nginx-related logs there.
cd backend/nginx
nginx -c "/path/to/Whisper-WebUI/backend/nginx/nginx.conf"
- Open another terminal in the root project location
/Whisper-WebUI
, and deploy the app withuvicorn
or whatever. Now the app will be available at your domain.
uvicorn backend.main:app --host 0.0.0.0 --port 8000
- When you turn off nginx, you can use
nginx -s stop
.
cd backend/nginx
nginx -s stop -c "/path/to/Whisper-WebUI/backend/nginx/nginx.conf"
You can set some server configurations in config.yaml.
For example, initial model size for Whisper or the cleanup frequency and TTL for cached files.
If the endpoint generates and saves the file, all output files are stored in the cache
directory, e.g. separated vocal/instrument files for /bgm-separation
are saved in cache
directory.
The Dockerfile should be built when you're in the root directory of Whisper-WebUI.
- git clone this repository
git clone https://github.com/jhj0517/Whisper-WebUI.git
- Mount volume paths with your local paths in
docker-compose.yaml
Whisper-WebUI/backend/docker-compose.yaml
Lines 12 to 15 in 1dd708e
- Build the image
docker compose -f backend/docker-compose.yaml build
- Run the container
docker compose -f backend/docker-compose.yaml up
- Then you can read docs at
localhost:8000
(default port is set to8000
indocker-compose.yaml
) and run your own tests.
The response can be obtained through the polling API. Each task is stored in the DB whenever the task is queued or updated by the process.
When the client first sends the POST
request, the server returns an identifier
to the client that can be used to track the status of the task. The task status is updated by the processes, and once the task is completed, the client can finally obtain the result.
The client needs to implement manual API polling to do this, this is the example for the python client:
def wait_for_task_completion(identifier: str,
max_attempts: int = 20,
frequency: int = 3) -> httpx.Response:
"""
Polls the task status every `frequency` until it is completed, failed, or the `max_attempts` are reached.
"""
attempts = 0
while attempts < max_attempts:
task = fetch_task(identifier)
status = task.json()["status"]
if status == "COMPLETED":
return task["result"]
if status == "FAILED":
raise Exception("Task polling failed")
time.sleep(frequency)
attempts += 1
return None