Skip to main content

codecov Test docs

Thunder speech

A Hackable speech recognition library.

What to expect from this project:

  • End-to-end speech recognition models
  • Simple fine-tuning to new languages
  • Inference support as a first-class feature
  • Developer oriented api

What it's not:

  • A general-purpose speech toolkit
  • A collection of complex systems that require thousands of gpu-hours and expert knowledge, only focusing on the state-of-the-art results

Quick usage guide

Install

Install the library from PyPI:

pip install thunder-speech

Load the model and train it

from thunder.registry import load_pretrained
from thunder.quartznet.compatibility import QuartznetCheckpoint

# Tab completion works to discover other QuartznetCheckpoint.*
module = load_pretrained(QuartznetCheckpoint.QuartzNet5x5LS_En)
# It also accepts the string identifier
module = load_pretrained("QuartzNet5x5LS_En")
# Or models from the huggingface hub
module = load_pretrained("facebook/wav2vec2-large-960h")

Export to a pure pytorch model using torchscript

module.to_torchscript("model_ready_for_inference.pt")

# Optional step: also export audio loading pipeline
from thunder.data.dataset import AudioFileLoader

loader = AudioFileLoader(sample_rate=16000)
scripted_loader = torch.jit.script(loader)
scripted_loader.save("audio_loader.pt")

Run inference in production

import torch
import torchaudio

model = torch.jit.load("model_ready_for_inference.pt")
loader = torch.jit.load("audio_loader.pt")
# Open audio
audio = loader("audio_file.wav")
# transcriptions is a list of strings with the captions.
transcriptions = model.predict(audio)

More quick tips

If you want to know how to access the raw probabilities and decode manually or fine-tune the models you can access the documentation here.

Contributing

The first step to contribute is to do an editable installation of the library:

git clone https://github.com/scart97/thunder-speech.git
cd thunder-speech
poetry install
pre-commit install

Then, make sure that everything is working. You can run the test suit, that is based on pytest:

RUN_SLOW=1 poetry run pytest

Here the RUN_SLOW flag is used to run all the tests, including the ones that might download checkpoints or do small training runs and are marked as slow. If you don't have a CUDA capable gpu, some tests will be unconditionally skipped.

Influences

This library has heavy influence of the best practices in the pytorch ecosystem. The original model code, including checkpoints, is based on the NeMo ASR toolkit. From there also came the inspiration for the fine-tuning and prediction api's.

The data loading and processing is loosely based on my experience using fast.ai. It tries to decouple transforms that happen at the item level from the ones that are efficiently implemented for the whole batch at the GPU. Also, the idea that default parameters should be great.

The overall organization of code and decoupling follows the pytorch-lightning ideals, with self-contained modules that try to reduce the boilerplate necessary.

Finally, the transformers library inspired the simple model implementations, with a clear separation in folders containing the specific code that you need to understand each architecture and preprocessing, and their strong test suit.

Metadata

Release files for thunder-speech 3.2.0

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

Source distribution (sdist)

Source distribution for thunder-speech 3.2.0
File Size Uploaded Provenance Actions
thunder-speech-3.2.0.tar.gz 36.1 kB Without provenance Details for thunder-speech-3.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for thunder-speech 3.2.0
File Interpreter ABI Platform Actions
thunder_speech-3.2.0-py3-none-any.whl Python 3 none any Details for thunder_speech-3.2.0-py3-none-any.whl

Total release size: 85.0 kB

Release files / thunder-speech-3.2.0.tar.gz

Download URL thunder-speech-3.2.0.tar.gz
Size 36.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b48642899b43c2b75391c8c024057efc41cab293d285b0c201860689d13814be
BLAKE2b-256 checksum
How to use checksums
cb4f7466d21cf0777cbbd551f40a305497e684d8883ae308eade5d574c8ccf1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/35.0 requests/2.28.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/4.12.0 keyring/23.7.0 rfc3986/2.0.0 colorama/0.4.5 CPython/3.9.13

Release files / thunder_speech-3.2.0-py3-none-any.whl

Download URL thunder_speech-3.2.0-py3-none-any.whl
Size 48.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ef727485605eab72de24b40e8b6bc1cd8ef9d068d6399e41811aa3fd81761af
BLAKE2b-256 checksum
How to use checksums
c3a6045e9d3bdf5ec1eb8f1c2bd600ada553fe8f99b0dc7928e5cb59444c2c84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.3 readme-renderer/35.0 requests/2.28.1 requests-toolbelt/0.9.1 urllib3/1.26.11 tqdm/4.64.0 importlib-metadata/4.12.0 keyring/23.7.0 rfc3986/2.0.0 colorama/0.4.5 CPython/3.9.13

Security for thunder-speech 3.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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