pip 安装会拉取无版本上限的 torch,可能装到超出本机 GPU 驱动支持的新版本,装完需用 torch.cuda.is_available() 验证;命令行推理默认走 CPU,有 GPU 也要显式加 --device cuda;训练/部署需另建 conda 环境并装 sox,否则可能报 sox extension 不可用,x86 runtime 或 LM 还需用 cmake 3.14+ 单独编译。
wenet
wenet-e2eApache-2.0活跃维护面向生产环境的端到端语音识别工具包,基于 PyTorch 提供 Conformer、Transformer 等模型,可直接训练和部署 ASR 服务。
Production First and Production Ready End-to-End Speech Recognition Toolkit
pip install git+https://github.com/wenet-e2e/wenet.git
wenet -m paraformer audio.wavREADME 未给出具体显存要求;推理默认在 CPU 上运行,需显式传 --device cuda 才用 GPU,Turing 架构(如 Tesla T4)另有 dtype 与 attention-backend 说明;训练推荐 CUDA 12.1,另支持华为昇腾 NPU(需装 CANN)。
面向生产的端到端语音识别工具包,提供从训练到部署的全栈方案
面向生产环境的端到端语音识别工具包,基于 PyTorch 提供 Conformer、Transformer 等模型,可直接训练和部署 ASR 服务。
核心能力
- 提供训练、推理到部署的全栈生产方案
- 在多个公开语音数据集上达到 SOTA 效果
- pip 安装即可用命令行或 Python API 转写音频
- 内置 paraformer、firered、whisper 等预训练模型
- 支持华为昇腾 NPU,并提供 torch-npu 依赖
容易踩的坑
- v3.1.0最新正式版2024-05-23 · 2024-05-23 03:25 UTC
❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
What's Changed
- [ctc] Update search.py by @pengzhendong in https://github.com/wenet-e2e/wenet/pull/2398
- fix mask to bias by @Mddct in https://github.com/wenet-e2e/wenet/pull/2401
- [ssl/w2vbert] weight copy from meta w2vbert-2.0 by @Mddct in https://github.com/wenet-e2e/wenet/pull/2392
- [lint] fix linter version by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2405
- [search] Update search.py by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2406
- fix mask bias dtype in sdpa by @Mddct in https://github.com/wenet-e2e/wenet/pull/2407
- Fix ckpt conversion bug by @zhr1201 in https://github.com/wenet-e2e/wenet/pull/2399
- [dataset] restrict batch type by @Mddct in https://github.com/wenet-e2e/wenet/pull/2410
- [wenet/bin/recognize.py] modify args to be consistent with train by @Mddct in https://github.com/wenet-e2e/wenet/pull/2411
- [transformer] remove pe to device by @Mddct in https://github.com/wenet-e2e/wenet/pull/2413
- add timer for steps by @Mddct in https://github.com/wenet-e2e/wenet/pull/2416
- [dataset] support repeat by @Mddct in https://github.com/wenet-e2e/wenet/pull/2415
- (!! breaking changes, we recommand
step_saveinstead ofepoch_save!!) 🚀🚀🚀
- (!! breaking changes, we recommand
- [transformer] fix sdpa u2pp training nan by @Mddct in https://github.com/wenet-e2e/wenet/pull/2419
- (!! important bug fix, enjoy flash attention without pain !!) 🚀🚀🚀
- [transformer] fix sdpa mask for ShowRelAttention by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2420
- [runtime/libtorch] fix jit issue by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2421
- [dataset] add shuffle at shards tar/raw file level by @kakashidan in https://github.com/wenet-e2e/wenet/pull/2424
- [dataset] fix cycle in recognize.py by @Mddct in https://github.com/wenet-e2e/wenet/pull/2426
- [dataset] unify shuf conf by @Mddct in https://github.com/wenet-e2e/wenet/pull/2427
- fix order by @Mddct in https://github.com/wenet-e2e/wenet/pull/2428
- [runtime] upgrade libtorch version to 2.1.0 by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2418
- [torchaudio] Fix torchaudio interface error (#2352) by @lsrami in https://github.com/wenet-e2e/wenet/pull/2429
- [paraformer] fsdp fix submodule call by @Mddct in https://github.com/wenet-e2e/wenet/pull/2431
- fix modify by @Mddct in https://github.com/wenet-e2e/wenet/pull/2436
- [deprecated dataset] small fix by @kakashidan in https://github.com/wenet-e2e/wenet/pull/2440
- [dataset] add singal channel conf & processor by @kakashidan in https://github.com/wenet-e2e/wenet/pull/2439
- fix list shuffle in recognize.py by @Mddct in https://github.com/wenet-e2e/wenet/pull/2446
- fix list_shuffle in cv_conf by @Mddct in https://github.com/wenet-e2e/wenet/pull/2447
- [runtime] Fixed failed compilation without ITN. Now, compiling ITN is mandatory. by @roney123 in https://github.com/wenet-e2e/wenet/pull/2444
- [runtime] add blank_sacle in ctc_endpoint by @jia-jidong in https://github.com/wenet-e2e/wenet/pull/2374
- fix step in continue training in steps mode by @Mddct in https://github.com/wenet-e2e/wenet/pull/2453
- fix export_jit.py by @Mddct in https://github.com/wenet-e2e/wenet/pull/2455
- [fix] fix copyright by @robin1001 in https://github.com/wenet-e2e/wenet/pull/2456
- [fix] fix copyright by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2457
- fix llama rope by @Mddct in https://github.com/wenet-e2e/wenet/pull/2459
- [train_engine] support fsdp by @Mddct in https://github.com/wenet-e2e/wenet/pull/2412
- (!! breaking changes, enjoy both fsdp & deepspeed !!) 🚀🚀🚀
- [env] update python version and deepspeed version by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2462
- (!! breaking changes, you may need to update your env !!) ❤❤❤
- fix rope pos embdining by @Mddct in https://github.com/wenet-e2e/wenet/pull/2463
- [transformer] add multi warmup and learning rate for diff
- v3.0.1WeNet 3.0.12024-03-09 · 2024-03-09 06:50 UTC
查看更新说明
❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
What's Changed
- Fix loss returned by CTC model in RNNT by @kobenaxie in https://github.com/wenet-e2e/wenet/pull/2327
- [dataset] new io for code reuse for many speech tasks by @Mddct in https://github.com/wenet-e2e/wenet/pull/2316
- (!! breaking changes, please update to torch2.x torchaudio2.x !!) 🚀🚀🚀
- Fix eot by @Qiaochu-Song in https://github.com/wenet-e2e/wenet/pull/2330
- [decode] support length penalty by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2331
- [bin] limit step when averaging model by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2332
- fix 'th_accuracy' not in transducer by @DaobinZhu in https://github.com/wenet-e2e/wenet/pull/2337
- [dataset] support bucket by seq length by @Mddct in https://github.com/wenet-e2e/wenet/pull/2333
- [examples] remove useless yaml by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2343
- [whisper] support arbitrary language and task by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2342
- (!! breaking changes, happy whisper happy life !!) 💯💯💯
- Minor fix decode_wav by @kobenaxie in https://github.com/wenet-e2e/wenet/pull/2340
- fix comment by @Mddct in https://github.com/wenet-e2e/wenet/pull/2344
- [w2vbert] support w2vbert fbank by @Mddct in https://github.com/wenet-e2e/wenet/pull/2346
- [dataset ] fix typo by @Mddct in https://github.com/wenet-e2e/wenet/pull/2347
- [wenet] fix args.enc by @Mddct in https://github.com/wenet-e2e/wenet/pull/2354
- [examples] Initial whisper results on wenetspeech by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2356
- [examples] fix --penalty by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2358
- [paraformer] add decoding args by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2359
- [transformer] support flash att by 'torch scaled dot attention' by @Mddct in https://github.com/wenet-e2e/wenet/pull/2351
- (!! breaking changes, please update to torch2.x torchaudio2.x !!) 🚀🚀🚀
- [conformer] support flash att by torch sdpa by @Mddct in https://github.com/wenet-e2e/wenet/pull/2360
- (!! breaking changes, please update to torch2.x torchaudio2.x !!) 🚀🚀🚀
- [conformer] sdpa default to false by @Mddct in https://github.com/wenet-e2e/wenet/pull/2362
- [transformer] fix bidecoder sdpa by @Mddct in https://github.com/wenet-e2e/wenet/pull/2368
- [runtime] Configurable blank token idx by @zhr1201 in https://github.com/wenet-e2e/wenet/pull/2366
- [wenet] modify - runtime/code/decoder more faster by @Sang-Hoon-Pakr in https://github.com/wenet-e2e/wenet/pull/2367
- (!! Significant improvement on warmup when using libtorch !!) 🚀🚀🚀
- [lint] fix lint by @cdliang11 in https://github.com/wenet-e2e/wenet/pull/2373
- [examples] better results on wenetspeech using revised transcripts by @xingchensong in https://github.com/wenet-e2e/wenet/pull/2371
- (!! Significant improvement on results of whisper !!) 💯💯💯
- [dataset] support pad or trim for whisper decoding by @Mddct in https://github.com/wenet-e2e/wenet/pull/2378
- [bin/recognize.py] support numworkers and compute dtype by @Mddct in https://github.com/wenet-e2e/wenet/pull/2379
- (!! Significant improvement on inference speed when using fp16 !!) 🚀🚀🚀
- [whisper] fix decoding maxlen by @Mddct in https://github.com/wenet-e2e/wenet/pull/2380
- fix whisper ckpt modify error by @fclearner in https://github.com/wenet-e2e/wenet/pull/2381
- 更新 recognize.py by @Mddct in https://github.com/wenet-e2e/wenet/pull/2383
- [transformer] add cross attention by @Mddct in https://github.com/wenet-e2e/wenet/pull/2388
- (!! Significant improvement on inference speed of attention_beam_search !!) 🚀🚀🚀
- [paraformer] fix some bugs by @Mddct in https://github.com/wenet-e2e/wenet/pull/2389
- new modules and methods by @Mddct in 🤩🤩🤩
- [transformer] support bias by @Mddct in https://github.com/wen
- v3.0.0WeNet 3.0.02024-01-25 · 2024-01-25 11:59 UTC
查看更新说明
❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤
New Features
- Support full part of bestrq #1869, #2060
- Support GPU Tlg streaming #1878
- Support streaming ASR web demo #1888
- Support k2 rnnt loss and delay penality #1909
- Supports context biasing #1931, #1936
- Support ZeroPrompt (not merged) #1943
- Support M1 Mac onnxruntime #1953
- Support ITN runtime #2001, #2042, #2246
- Support wav2vec2 #2034, #2035
- Support part of w2vbert training #2039
- wenet cli #2047, #2054, #2075, #2082, #2088, #2087, https://github.com/wenet-e2e/wenet/pull/2098, https://github.com/wenet-e2e/wenet/pull/2101, #2122 (!! simple and fast !!) 🛫
- Support E-Branchformer module #2013
- Support deepspeed #1849, #2168, #2123 (!! big big big !!) 💯
- LoRA support (not merged) #2049
- support batch decoding for ctc_prefix_beam_search & attention_rescoring #2059 (!! simple and fast !!) 🛫
- support ali-paraformer #2067, #2078, https://github.com/wenet-e2e/wenet/pull/2093, https://github.com/wenet-e2e/wenet/pull/2096, https://github.com/wenet-e2e/wenet/pull/2099, #2124, #2139, #2140, #2155, #2219, #2222, #2277, #2282, #2289, #2314, #2324
- support Contrastive learning for unified models #2100
- support context biasing with ac automaton #2128, #2136
- support whisper arch #2141, #2157, #2196, #2313, #2322, #2323
- Support gradient checkpointing for Conformer & Transformer (whisper) #2173, #2275
- ssh-launcher for multi-node multi-gpu training #2180, #2265
- u2++-lite training support #2202
- support blank penalty #2278
- support speaker in dataset #2292
- Whisper inference support in cpp runtime #2320
What's Changed
- Upgrade libtorch CPU runtime with IPEX version #1893
- Refine ctc alignment #1966
- Use torchrun for distributed training #2020, #2021
- Refine traning code #2055, #2103, #2123, #2248, #2252, #2253, #2270, #2286, #2288, #2312 (!! big changes !!) 🚀
- mv all ctc functions to ctc_utils.py #2057 (!! big changes !!) 🚀
- move search methods to search.py #2056 (!! big changes !!) 🚀
- move all k2 related functions to k2 #2058
- refactor and simplify decoding methods #2061, #2062
- unify decode results of all decoding methods #2063
- refactor(dataset): return dict instead of tuple #2106, #2111
- init_model API changed #2116, #2216 (!! big changes !!) 🚀
- move yaml saving to save_model() #2156
- refine tokenizer #2165, #2186 (!! big changes !!) 🚀
- deprecate wenetruntime #2194 (!! big changes !!) 🚀
- use pre-commit to auto check and lint #2195
- refactor(yaml): Config ctc/cmvn/tokenizer in train.yaml #2205, #2229, #2230, #2227, #2232 (!! big changes !!) 🚀
- train with dict input #2242, #2243 (!! big changes !!) 🚀
- [dataset] keep pcm for other task #2268
- Updgrad torch to 2.x #2301 (!! big changes !!) 🚀
- log everything to tensorboard #2307
New Bug Fixes
- Fix NST recipe #1863
- Fix Librispeech fst dict #1929
- Fix bug when make shard.list for *.flac #1933
- Fix bug of transducer #1940
- Avoid problem during model averaging when there is parameter-tying. #2113
- [loss] set zero_infinity=True to ignore NaN or inf ctc_loss #2299
- fix android #2303
❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤ Many thanks to all the contributors !!!!! I love u all.
- v2.2.1WeNet 2.2.12023-05-26 · 2023-05-26 05:08 UTC
查看更新说明
What's Changed
- Add http server/client @aluminumbox #1670
- Add Trt (Myelin) support for streaming ASR @yuekaizhang #1679
- Support OpenVino @FionaZZ92 #1700
- Support ONNX GPU export, add librispeech results, and fix V2 streaming decode issue for efficient conformer @zwglory #1701
- Support ort backend in wenetruntime @xingchensong #1708
- Support LFMMI @aluminumbox #1725
- Support Paraformer @MrSupW & @robin1001 #1738 & #1749 & #1791 & #1795
- Support part of bestrq @Mddct #1750 & #1754 & #1824
- Remove concat after to simplify the code flow #1762 & #1763 & #1764
- Add riva cuda tlg decoder @yuekaizhang #1773
- Add CUDA TLG nbest and mbr decoding @yuekaizhang #1804
- Support IPEX @ZailiWang #1816
- Support Branchformer @kli017 #1845
- Support GPU hotword @zwglory #1860
- v2.2.0WeNet 2.2.02023-01-15 · 2023-01-15 09:55 UTC
查看更新说明
What's Changed
- support exporting squeezeformer to onnx (CPU & GPU) by @yygle in #1593 and #1634
- support horizon x3 pi by @xingchensong in #1597
- support noisy student training by @NevermoreCY in #1600
- support efficient conformer by @zwglory in #1636
- add blank scale for wfst decoding by @simonwang517 in #1646
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
WeNet
Roadmap | Docs | Papers | Runtime | Pretrained Models | HuggingFace | Ask WeNet Guru
We share Net together.
Highlights
- Production first and production ready: The core design principle, WeNet provides full stack production solutions for speech recognition.
- Accurate: WeNet achieves SOTA results on a lot of public speech datasets.
- Light weight: WeNet is easy to install, easy to use, well designed, and well documented.
Install
Install python package
pip install git+https://github.com/wenet-e2e/wenet.git
This pulls in torch>=1.13.0 with no upper bound, so pip may install a torch
build newer than your installed GPU driver supports. If you plan to use a GPU,
verify it after install:
python -c "import torch; print(torch.cuda.is_available())"
If this prints False on a machine with a GPU, torch silently falls back to
CPU with no error. Reinstall a torch build matching your driver's CUDA
version, e.g.:
pip install torch==2.4.0+cu121 torchaudio==2.4.0+cu121 --index-url https://download.pytorch.org/whl/cu121 --force-reinstall
Command-line usage (use -h for parameters):
wenet -m paraformer audio.wav
You can set -m with paraformer or firered or wenetspeech for chinese,
and set it to whisper-large-v3 or whisper-large-v3-turbo for english.
Note: this runs on CPU by default (--device defaults to cpu), even if
a GPU is available. Pass --device cuda explicitly to use the GPU (Python API:
wenet.load_model(model_name, device='cuda')). See
python usage for GPU/Turing (e.g.
Tesla T4) specific notes on dtype and attention-backend options.
Python programming usage:
import wenet
model = wenet.load_model('paraformer')
result = model.transcribe('audio.wav')
print(result.text)
Please refer python usage for more command line and python programming usage.
Install for training & deployment
- Clone the repo
git clone https://github.com/wenet-e2e/wenet.git
- Install Conda: please see https://docs.conda.io/en/latest/miniconda.html
- Create Conda env:
conda create -n wenet python=3.10
conda activate wenet
conda install conda-forge::sox
- Install CUDA: please follow this link, It's recommended to install CUDA 12.1
- Install torch and torchaudio, It's recomended to use 2.2.2+cu121:
pip install torch==2.2.2+cu121 torchaudio==2.2.2+cu121 -f https://download.pytorch.org/whl/torch_stable.html
-
Install CANN: please follow this link to install CANN toolkit and kernels.
-
Install WeNet with torch-npu dependencies:
pip install -e .[torch-npu]
- Related version control table:
| Requirement | Minimum | Recommend |
|---|---|---|
| CANN | 8.0.RC2.alpha003 | latest |
| torch | 2.1.0 | 2.2.0 |
| torch-npu | 2.1.0 | 2.2.0 |
| torchaudio | 2.1.0 | 2.2.0 |
| deepspeed | 0.13.2 | latest |
- Install other python packages
pip install -r requirements.txt
pre-commit install # for clean and tidy code
- Frequently Asked Questions (FAQs)
# If you encounter sox compatibility issues
RuntimeError: set_buffer_size requires sox extension which is not available.
# ubuntu
sudo apt-get install sox libsox-dev
# centos
sudo yum install sox sox-devel
# conda env
conda install conda-forge::sox
Build for deployment
Optionally, if you want to use x86 runtime or language model(LM), you have to build the runtime as follows. Otherwise, you can just ignore this step.
# runtime build requires cmake 3.14 or above
cd runtime/libtorch
mkdir build && cd build && cmake -DGRAPH_TOOLS=ON .. && cmake --build .
Please see doc for building runtime on more platforms and OS.
Discussion & Communication
You can directly discuss on Github Issues.
For Chinese users, you can also scan the QR code on the left to follow our official account of WeNet. We created a WeChat group for better discussion and quicker response. Please scan the personal QR code on the right, and the guy is responsible for inviting you to the chat group.
Acknowledge
- We borrowed a lot of code from ESPnet for transformer based modeling.
- We borrowed a lot of code from Kaldi for WFST based decoding for LM integration.
- We referred EESEN for building TLG based graph for LM integration.
- We referred to OpenTransformer for python batch inference of e2e models.
Citations
@inproceedings{yao2021wenet,
title={WeNet: Production oriented Streaming and Non-streaming End-to-End Speech Recognition Toolkit},
author={Yao, Zhuoyuan and Wu, Di and Wang, Xiong and Zhang, Binbin and Yu, Fan and Yang, Chao and Peng, Zhendong and Chen, Xiaoyu and Xie, Lei and Lei, Xin},
booktitle={Proc. Interspeech},
year={2021},
address={Brno, Czech Republic },
organization={IEEE}
}
@article{zhang2022wenet,
title={WeNet 2.0: More Productive End-to-End Speech Recognition Toolkit},
author={Zhang, Binbin and Wu, Di and Peng, Zhendong and Song, Xingchen and Yao, Zhuoyuan and Lv, Hang and Xie, Lei and Yang, Chao and Pan, Fuping and Niu, Jianwei},
journal={arXiv preprint arXiv:2203.15455},
year={2022}
}