Skip to main content

PyPI - Version PyPI - Python Version PyPI - License PyPI - Downloads codecov

Speech Recognition API

Simple but extensible API for Speech Recognition.

Installation

From pip:

pip install speech_recognition_api[all]

From git:

git clone https://github.com/asai95/speech-recognition-api.git
pip install -r requirements.txt

Usage

Simple dev server:

python -m speech_recognition_api

Gunicorn:

gunicorn "speech_recognition_api:create_app()" -k uvicorn.workers.UvicornWorker -w 1 -b 127.0.0.1:8888

Celery worker:

celery -A speech_recognition_api.extra.celery_bus worker

Huey worker:

huey_consumer speech_recognition_api.extra.huey_bus.huey

Description

This project is aimed to simplify building and deploying of applications that require Speech Recognition functionality.

It is designed to work as a microservice, so it does not handle stuff like auth and rate limits.

However, it is also designed to be extensible in 3 major areas:

  • Models
  • File Storages
  • Message Busses

There are two types of APIs available.

Synchronous API

This API is designed for simple workloads, where the machine that runs the server is capable of running a model. You probably want to limit the payload size for these routes.

Routes:

POST /sync/v1/transcribe

Accepts an audio file. File type depends on the model that is being used.

Returns an object with transcription. Response model.

Asynchronous API

This API is designed to process files asynchronously, i.e. to create tasks and process them on separate workers. Typical client flow here is as follows:

  • Create a task and receive task id
  • Use this task id to periodically check if it is completed.

Routes:

POST /async/v1/transcribe

Accepts an audio file. File type depends on the model that is being used.

Returns an object with async task id. Response model.

GET /async/v1/transcribe/{task_id}

Returns an object with status and a transcription (if transcription is available). Response model.

Async API also requires a worker to run the actual work.

Configuring

Configuration is done by .env file or env variables (they take preference).

The main variables required for the API and worker to run are:

  • MODEL - model class path (it will do the actual audio-to-text conversion)
  • STORAGE - storage class path (in Async API it will be responsible for uploading/downloading files)
  • MESSAGE_BUS - message bus class path (in Async API it will be responsible for sending tasks to remoted workers and getting the result back from them)

These classes will be imported only when used for the fist time.

Each class may require its own variables. Please refer to config.py of the specific module to get the config reference.

Built-in classes:

Models:

Storages:

Message Busses:

Extending

It is easy to extend the API by adding models, storages and message busses.

To do that, one can just create a class that implements an interface:

Then just add a path to the class to the config file and that's it!

I suggest to distribute new modules through PyPI, so other people could reuse them.

Metadata

Release files for speech-recognition-api 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for speech-recognition-api 0.1.1
File Size Uploaded
speech-recognition-api-0.1.1.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for speech-recognition-api 0.1.1
File Interpreter ABI Platform
speech_recognition_api-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 42.8 kB

Release files / speech-recognition-api-0.1.1.tar.gz

Download URL speech-recognition-api-0.1.1.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f53c54a9c3328876721fc9f3e9f5f80b2ea4afc9f86a929552f75e73b2d5c257
BLAKE2b-256 checksum
How to use checksums
74fd57eb039e2a5176dd6e182f135f58500c3e94fc9ec8c884489be8100b69de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / speech_recognition_api-0.1.1-py3-none-any.whl

Download URL speech_recognition_api-0.1.1-py3-none-any.whl
Size 27.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b19ce26bb2331884d9b9905e35d447c7fb16bc786358c142c96788276147ee84
BLAKE2b-256 checksum
How to use checksums
b9f44b2104cbdf9c21a67332ee1737d69fcb52e097f3c380537057778ae8f531
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page