Wenet STT Python

Overview

Wenet STT Python

Beta Software

Simple Python library, distributed via binary wheels with few direct dependencies, for easily using WeNet models for speech recognition.

Donate Donate Donate

Requirements:

  • Python 3.7+ x64
  • Platform: Windows/Linux/MacOS
  • Python package requirements: cffi, numpy
  • Wenet Model (must be "runtime" format)
    • Several are available ready-to-go on this project's releases page and below.

Features:

  • Synchronous decoding of single utterance
  • Streaming decoding, using separate thread

Models:

Model Download Size
gigaspeech_20210728_u2pp_conformer 549 MB
gigaspeech_20210811_conformer_bidecoder 540 MB

Usage

from wenet_stt import WenetSTTModel
model = WenetSTTModel(WenetSTTModel.build_config('model_dir'))

import wave
with wave.open('tests/test.wav', 'rb') as wav_file:
    wav_samples = wav_file.readframes(wav_file.getnframes())

assert model.decode(wav_samples).lower() == 'it depends on the context'

Also contains a simple CLI interface for recognizing wav files:

$ python -m wenet_stt decode model test.wav
IT DEPENDS ON THE CONTEXT
$ python -m wenet_stt decode model test.wav test.wav
IT DEPENDS ON THE CONTEXT
IT DEPENDS ON THE CONTEXT
$ python -m wenet_stt -h
usage: python -m wenet_stt [-h] {decode} ...

positional arguments:
  {decode}    sub-command
    decode    decode one or more WAV files

optional arguments:
  -h, --help  show this help message and exit

Installation/Building

Recommended installation via binary wheel from pip (requires a recent version of pip):

python -m pip install wenet_stt

For details on building from source, see the Github Actions build workflow.

Author

License

This project is licensed under the GNU Affero General Public License v3 (AGPL-3.0-or-later). See the LICENSE file for details. If this license is problematic for you, please contact me.

Acknowledgments

  • Contains and uses code from WeNet, licensed under the Apache-2.0 License, and other transitive dependencies (see source).
You might also like...
Space-invaders - Simple Game created using Python & PyGame, as my Beginner Python Project
Space-invaders - Simple Game created using Python & PyGame, as my Beginner Python Project

Space Invaders This is a simple SPACE INVADER game create using PYGAME whihc hav

Snapchat-filters-app-opencv-python - Here we used opencv and other inbuilt python modules to create filter application like snapchat Yolov5-opencv-cpp-python - Example of using ultralytics YOLO V5 with OpenCV 4.5.4, C++ and Python
Yolov5-opencv-cpp-python - Example of using ultralytics YOLO V5 with OpenCV 4.5.4, C++ and Python

yolov5-opencv-cpp-python Example of performing inference with ultralytics YOLO V

Python-kafka-reset-consumergroup-offset-example - Python Kafka reset consumergroup offset example

Python Kafka reset consumergroup offset example This is a simple example of how

Experimental Python implementation of OpenVINO Inference Engine (very slow, limited functionality). All codes are written in Python. Easy to read and modify.
Experimental Python implementation of OpenVINO Inference Engine (very slow, limited functionality). All codes are written in Python. Easy to read and modify.

PyOpenVINO - An Experimental Python Implementation of OpenVINO Inference Engine (minimum-set) Description The PyOpenVINO is a spin-off product from my

A python-image-classification web application project, written in Python and served through the Flask Microframework
A python-image-classification web application project, written in Python and served through the Flask Microframework

A python-image-classification web application project, written in Python and served through the Flask Microframework. This Project implements the VGG16 covolutional neural network, through Keras and Tensorflow wrappers, to make predictions on uploaded images.

A python-image-classification web application project, written in Python and served through the Flask Microframework. This Project implements the VGG16 covolutional neural network, through Keras and Tensorflow wrappers, to make predictions on uploaded images.
PyArmadillo: an alternative approach to linear algebra in Python

PyArmadillo is a linear algebra library for the Python language, with an emphasis on ease of use.

Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more
Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler; for Python, R, Julia, Scala, Go, Javascript and more

Apache MXNet (incubating) for Deep Learning Apache MXNet is a deep learning framework designed for both efficiency and flexibility. It allows you to m

Comments
  • library dependency failures

    library dependency failures

    when running decode, i get a library linking issue python -m wenet_stt decode model test.wav

      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/runpy.py", line 194, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/__main__.py", line 46, in <module>
        main()
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/__main__.py", line 24, in main
        wenet_stt = WenetSTTModel(WenetSTTModel.build_config(args.model_dir))
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/wrapper.py", line 71, in __init__
        super().__init__()
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/wrapper.py", line 35, in __init__
        self.init_ffi()
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/wrapper.py", line 39, in init_ffi
        cls._lib = _ffi.init_once(cls._init_ffi, cls.__name__ + '._init_ffi')
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/cffi/api.py", line 749, in init_once
        result = func()
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/wrapper.py", line 48, in _init_ffi
        return _ffi.dlopen(_library_binary_path)
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/cffi/api.py", line 150, in dlopen
        lib, function_cache = _make_ffi_library(self, name, flags)
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/cffi/api.py", line 832, in _make_ffi_library
        backendlib = _load_backend_lib(backend, libname, flags)
      File "/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/cffi/api.py", line 827, in _load_backend_lib
        raise OSError(msg)
    OSError: cannot load library '/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/libwenet_stt_lib.dylib': dlopen(/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/libwenet_stt_lib.dylib, 0x0002): Library not loaded: @rpath/libtorch.dylib
      Referenced from: /Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/libwenet_stt_lib.dylib
      Reason: tried: '/private/var/folders/w_/vt72cbr92797v0q4r91wk8380000gn/T/pip-req-build-tp3um_02/native/wenet/runtime/server/x86/fc_base/openfst-subbuild/openfst-populate-prefix/lib/libtorch.dylib' (no such file), '/private/var/folders/w_/vt72cbr92797v0q4r91wk8380000gn/T/pip-req-build-tp3um_02/native/wenet/runtime/server/x86/fc_base/libtorch-src/lib/libtorch.dylib' (no such file), '/private/var/folders/w_/vt72cbr92797v0q4r91wk8380000gn/T/pip-req-build-tp3um_02/native/wenet/runtime/server/x86/fc_base/openfst-subbuild/openfst-populate-prefix/lib/libtorch.dylib' (no such file), '/private/var/folders/w_/vt72cbr92797v0q4r91wk8380000gn/T/pip-req-build-tp3um_02/native/wenet/runtime/server/x86/fc_base/libtorch-src/lib/libtorch.dylib' (no such file), '/Users/myuser/opt/miniconda3/envs/wenet/lib/libtorch.dylib' (no such file), '/Users/myuser/opt/miniconda3/envs/wenet/bin/../lib/libtorch.dylib' (no such file), '/usr/local/lib/libtorch.dylib' (no such file), '/usr/lib/libtorch.dylib' (no such file).  Additionally, ctypes.util.find_library() did not manage to locate a library called '/Users/myuser/opt/miniconda3/envs/wenet/lib/python3.8/site-packages/wenet_stt/libwenet_stt_lib.dylib'```
    opened by eschmidbauer 0
  • Issues with LM (TLG-rescoring)

    Issues with LM (TLG-rescoring)

    I'm trying to use CTC WFST-search for rescoring with compiled TLG graph using this tutorial: https://wenet-e2e.github.io/wenet/lm.html and passing these parameters to decoder: config = { "model_path": f"wenet/{model_name}/final.zip", "dict_path": f"wenet/{model_name}/words.txt", "rescoring_weight": 1.0, "blank_skip_thresh": 0.98, "beam": 15.0, "lattice_beam": 7.5, "min_active": 10, "max_active": 7000, "ctc_weight": 0.5, "reverse_weight": 0.0, "chunk_size": -1, "fst_path": f"wenet/examples/aishell/s0/data/lang_test/TLG.fst" }

    However I'm getting error: `ERROR: FstImpl::ReadHeader: FST not of type vector, found qq: wenet/examples/aishell/s0/data/lang_test/TLG.fst F1102 22:28:04.138978 26002 wenet_stt_lib.cpp:160] Check failed: fst != nullptr *** Check failure stack trace: *** @ 0x7f81d6cfb38d google::LogMessage::Fail() @ 0x7f81d6cfd604 google::LogMessage::SendToLog() @ 0x7f81d6cfaec0 google::LogMessage::Flush() @ 0x7f81d6cfdd89 google::LogMessageFatal::~LogMessageFatal() @ 0x7f81e83701b5 InitDecodeResourceFromSimpleJson() @ 0x7f81e8380ebc WenetSTTModel::WenetSTTModel() @ 0x7f81e83719bb wenet_stt__construct @ 0x7f82021b7dec ffi_call_unix64 @ 0x7f82021b6f55 ffi_call @ 0x7f82023d9e56 cdata_call @ 0x5da58b _PyObject_FastCallKeywords @ 0x54bc71 (unknown) @ 0x552d2d _PyEval_EvalFrameDefault @ 0x54cb89 _PyEval_EvalCodeWithName @ 0x5dac6e _PyFunction_FastCallDict @ 0x590713 (unknown) @ 0x5da1c9 _PyObject_FastCallKeywords @ 0x552fb7 _PyEval_EvalFrameDefault @ 0x54c522 _PyEval_EvalCodeWithName @ 0x54e933 PyEval_EvalCode @ 0x6305a2 (unknown) @ 0x630657 PyRun_FileExFlags @ 0x6312cf PyRun_SimpleFileExFlags @ 0x654232 (unknown) @ 0x65458e _Py_UnixMain @ 0x7f820422fb97 __libc_start_main @ 0x5e0cca _start @ (nil) (unknown) Aborted

    The same TLG-graph works fine when I'm using the default WeNet decoder. Ubuntu 18.04.

    opened by tonko22 0
Owner
David Zurow
david.zurow at gmail
David Zurow
Exploring Versatile Prior for Human Motion via Motion Frequency Guidance (3DV2021)

Exploring Versatile Prior for Human Motion via Motion Frequency Guidance This is the codebase for video-based human motion reconstruction in human-mot

Jiachen Xu 5 Jul 14, 2022
A Python package for time series augmentation

tsaug tsaug is a Python package for time series augmentation. It offers a set of augmentation methods for time series, as well as a simple API to conn

Arundo Analytics 278 Jan 01, 2023
GyroSPD: Vector-valued Distance and Gyrocalculus on the Space of Symmetric Positive Definite Matrices

GyroSPD Code for the paper "Vector-valued Distance and Gyrocalculus on the Space of Symmetric Positive Definite Matrices" accepted at NeurIPS 2021. Re

Federico Lopez 12 Dec 12, 2022
Alphabetical Letter Recognition

DecisionTrees-Image-Classification Alphabetical Letter Recognition In these demo we are using "Decision Trees" Our database is composed by Learning Im

Mohammed Firass 4 Nov 30, 2021
Python package provinding tools for artistic interactive applications using AI

Documentation redrawing Python package provinding tools for artistic interactive applications using AI Created by ReDrawing Campinas team for the Open

ReDrawing Campinas 1 Sep 30, 2021
AdaFocus V2: End-to-End Training of Spatial Dynamic Networks for Video Recognition

AdaFocusV2 This repo contains the official code and pre-trained models for AdaFo

79 Dec 26, 2022
OcclusionFusion: realtime dynamic 3D reconstruction based on single-view RGB-D

OcclusionFusion (CVPR'2022) Project Page | Paper | Video Overview This repository contains the code for the CVPR 2022 paper OcclusionFusion, where we

Wenbin Lin 193 Dec 15, 2022
TorchFlare is a simple, beginner-friendly, and easy-to-use PyTorch Framework train your models effortlessly.

TorchFlare TorchFlare is a simple, beginner-friendly and an easy-to-use PyTorch Framework train your models without much effort. It provides an almost

Atharva Phatak 85 Dec 26, 2022
Latex code for making neural networks diagrams

PlotNeuralNet Latex code for drawing neural networks for reports and presentation. Have a look into examples to see how they are made. Additionally, l

Haris Iqbal 18.6k Jan 01, 2023
This package is for running the semantic SLAM algorithm using extracted planar surfaces from the received detection

Semantic SLAM This package can perform optimization of pose estimated from VO/VIO methods which tend to drift over time. It uses planar surfaces extra

Hriday Bavle 125 Dec 02, 2022
Deep Face Recognition in PyTorch

Face Recognition in PyTorch By Alexey Gruzdev and Vladislav Sovrasov Introduction A repository for different experimental Face Recognition models such

Alexey Gruzdev 141 Sep 11, 2022
Prototypical Pseudo Label Denoising and Target Structure Learning for Domain Adaptive Semantic Segmentation (CVPR 2021)

Prototypical Pseudo Label Denoising and Target Structure Learning for Domain Adaptive Semantic Segmentation (CVPR 2021, official Pytorch implementatio

Microsoft 247 Dec 25, 2022
JASS: Japanese-specific Sequence to Sequence Pre-training for Neural Machine Translation

JASS: Japanese-specific Sequence to Sequence Pre-training for Neural Machine Translation This the repository for this paper. Find extensions of this w

Zhuoyuan Mao 14 Oct 26, 2022
Benchmarking Pipeline for Prediction of Protein-Protein Interactions

B4PPI Benchmarking Pipeline for the Prediction of Protein-Protein Interactions How this benchmarking pipeline has been built, and how to use it, is de

Loïc Lannelongue 4 Jun 27, 2022
This framework implements the data poisoning method found in the paper Adversarial Examples Make Strong Poisons

Adversarial poison generation and evaluation. This framework implements the data poisoning method found in the paper Adversarial Examples Make Strong

31 Nov 01, 2022
A-ESRGAN aims to provide better super-resolution images by using multi-scale attention U-net discriminators.

A-ESRGAN: Training Real-World Blind Super-Resolution with Attention-based U-net Discriminators The authors are hidden for the purpose of double blind

77 Dec 16, 2022
Dense matching library based on PyTorch

Dense Matching A general dense matching library based on PyTorch. For any questions, issues or recommendations, please contact Prune at

Prune Truong 399 Dec 28, 2022
Stratified Transformer for 3D Point Cloud Segmentation (CVPR 2022)

Stratified Transformer for 3D Point Cloud Segmentation Xin Lai*, Jianhui Liu*, Li Jiang, Liwei Wang, Hengshuang Zhao, Shu Liu, Xiaojuan Qi, Jiaya Jia

DV Lab 195 Jan 01, 2023
Add-on for importing and auto setup of character creator 3 character exports.

CC3 Blender Tools An add-on for importing and automatically setting up materials for Character Creator 3 character exports. Using Blender in the Chara

260 Jan 05, 2023
Single-stage Keypoint-based Category-level Object Pose Estimation from an RGB Image

CenterPose Overview This repository is the official implementation of the paper "Single-stage Keypoint-based Category-level Object Pose Estimation fro

NVIDIA Research Projects 188 Dec 27, 2022