# WeNet

> Production-first end-to-end speech recognition, from training recipe to deployed runtime

- Category: Multimodal Generation / Audio, Music & Voice
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/wenet-e2e/wenet
- Website: https://wenet-e2e.github.io/wenet/
- Canonical page: https://ai-tldr.dev/tools/wenet/

## In short

WeNet is an open-source speech recognition toolkit built around a single stated design principle: production first and production ready. It sits in the Audio, Music & Voice category of the Multimodal Generation tools and is open-source, written in Python and licensed Apache-2.0. To get started: install the Python package.

## Overview

WeNet is an open-source speech recognition toolkit built around a single stated design principle: production first and production ready. Where many ASR projects stop at a research checkpoint, WeNet is organised so that the same model you train is the model you ship — the repository carries the training recipes, the pretrained models, and a separate C++ runtime you build for deployment.

Day to day it has two faces. The Python package is the quick one: install it, point the `wenet` command at a WAV file, and get a transcript back, choosing between Chinese models (`paraformer`, `firered`, `wenetspeech`) and English Whisper checkpoints (`whisper-large-v3`, `whisper-large-v3-turbo`). The full clone is the other: a conda environment with PyTorch, the dataset recipes, and an optional CMake build under `runtime/libtorch` for x86 deployment or language-model integration.

The project is a long-running academic-industrial effort — the README credits ESPnet for its transformer modelling, Kaldi for WFST-based decoding with language models, and EESEN for TLG graph construction, and cites the Interspeech 2021 WeNet paper and the WeNet 2.0 follow-up. It runs on CPU by default, on NVIDIA GPUs with a matching CUDA build of torch, and on Ascend NPUs through the `torch-npu` extra.

## What it does

- Pip-installable CLI and Python API: `wenet -m paraformer audio.wav` from the shell, or `wenet.load_model(...)` plus `model.transcribe(...)` in code
- Pretrained models for both Chinese (paraformer, firered, wenetspeech) and English (whisper-large-v3, whisper-large-v3-turbo) selected with a single `-m` flag
- Full training and fine-tuning recipes in the repository, alongside a conda environment spec and pinned torch/torchaudio versions
- A separate C++ runtime you build with CMake for x86 deployment and language-model (LM) integration, with docs covering more platforms
- Ascend NPU support through the `.[torch-npu]` extra, with a documented CANN/torch/torch-npu version compatibility table
- Explicit device control — CPU by default, `--device cuda` (or `device='cuda'` in Python) to move onto the GPU

## Getting started

For transcription, the pip package is enough. Training and deployment use the full clone instead — the README keeps those two paths separate on purpose.

1. Install the Python package

   The package installs straight from the repository and pulls in torch 1.13 or newer.

```bash
pip install git+https://github.com/wenet-e2e/wenet.git
```

2. Check your torch build sees the GPU

   The install has no upper bound on torch, so pip can land a build newer than your driver supports. If this prints False on a GPU machine, torch silently falls back to CPU — reinstall a build matching your driver's CUDA version.

```bash
python -c "import torch; print(torch.cuda.is_available())"
```

3. Transcribe from the command line

   Pick the model with -m: paraformer, firered or wenetspeech for Chinese, whisper-large-v3 or whisper-large-v3-turbo for English. This runs on CPU unless you pass --device cuda.

```bash
wenet -m paraformer audio.wav
```

4. Or call it from Python

   The Python API loads the same models and returns a result object carrying the transcript.

```python
import wenet

model = wenet.load_model('paraformer')
result = model.transcribe('audio.wav')
print(result.text)
```

5. Set up for training and deployment

   Training uses the full clone in a conda environment. The README recommends CUDA 12.1 with torch 2.2.2+cu121.

```bash
git clone https://github.com/wenet-e2e/wenet.git
conda create -n wenet python=3.10
conda activate wenet
conda install conda-forge::sox
pip install torch==2.2.2+cu121 torchaudio==2.2.2+cu121 -f https://download.pytorch.org/whl/torch_stable.html
pip install -r requirements.txt
```

6. Build the runtime (only if you need it)

   Skip this unless you want the x86 runtime or language-model integration. Requires CMake 3.14 or above; see the runtime docs for other platforms.

```bash
cd runtime/libtorch
mkdir build && cd build && cmake -DGRAPH_TOOLS=ON .. && cmake --build .
```

## When to use it

- Transcribe Chinese or English audio from a script or notebook without standing up a service, using the pip package and a pretrained model
- Train or fine-tune an end-to-end ASR model on your own data with the repository's recipes, then deploy the same model through the C++ runtime
- Add language-model integration to decoding via the WFST/TLG path when domain vocabulary matters more than raw end-to-end accuracy
- Run speech recognition on Ascend NPU hardware using the documented torch-npu extra and CANN version table
