FastAPI implementation of the web Speech to Code API.
This package uses Poetry for dependency management.
- Install the
api
usingpoetry install
. - Run the API locally using
poetry run start
. (this callsapi.main:start
)
You will then be able to access the API on http://0.0.0.0:8000/
.
Note: You can control the port using the
PORT
environment variable. :)
This is the entrypoint of the Speech to Code API. It accepts audio file upload via the request body form-data. To use it, hit it with a post request with a WAV-file submitted under the audio
key.
This will create a new task, which is immediately queued.
Using curl
, a request can be submitted with:
curl -X POST -F "[email protected]" http://0.0.0.0:8000/task
This will return a HTTP 200, with contents similar to:
{
"task_id": "c92ecf6e14814c2a9289a3e276797e4c"
}
Once a task is queued, it may take some time for it to start processing, and subsequently to finish. This endpoint gets the current status of the task, and will provide the task result once it's done.
Simply send a GET request to the endpoint corresponding to the task_id
received from POST /task
to observe the status.
You can use this endpoint by curl
'ing the route. Like this:
curl http://0.0.0.0:8000/task/c92ecf6e14814c2a9289a3e276797e4c
This will respond with a HTTP 200, containing the following (in chronological order):
- In the queued state.
{
"status": "queueing",
"result": null
}
- When a processing worker has picked up the task.
{
"status": "processing",
"result": null
}
- When the task is done processing. 🎉
{
"status": "done",
"result": "<code from speech>"
}
Building the Docker image must be done from the root (..
from here) context to include the common
package. You can build the API image from the root directory containing api/
, like this:
docker build -t speech-to-codeapi -f api/docker/Dockerfile .
Note: This will require mounting relevant Azure credentials, or passing environment credentials to the container.