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
tinykernel - A minimal Python kernel so you can run Python in your Python

tinykernel - A minimal Python kernel so you can run Python in your Python

fast.ai 37 Dec 2, 2022
Python-experiments - A Repository which contains python scripts to automate things and make your life easier with python

Python Experiments A Repository which contains python scripts to automate things

Vivek Kumar Singh 11 Sep 25, 2022
Crab is a flexible, fast recommender engine for Python that integrates classic information filtering recommendation algorithms in the world of scientific Python packages (numpy, scipy, matplotlib).

Crab - A Recommendation Engine library for Python Crab is a flexible, fast recommender engine for Python that integrates classic information filtering r

python-recsys 1.2k Dec 21, 2022
Python scripts to detect faces in Python with the BlazeFace Tensorflow Lite models

Python scripts to detect faces using Python with the BlazeFace Tensorflow Lite models. Tested on Windows 10, Tensorflow 2.4.0 (Python 3.8).

Ibai Gorordo 46 Nov 17, 2022
A fast python implementation of Ray Tracing in One Weekend using python and Taichi

ray-tracing-one-weekend-taichi A fast python implementation of Ray Tracing in One Weekend using python and Taichi. Taichi is a simple "Domain specific

null 157 Dec 26, 2022
Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! Very tiny! Stock Market Financial Technical Analysis Python library . Quant Trading automation or cryptocoin exchange

MyTT Technical Indicators implemented in Python only using Numpy-Pandas as Magic - Very Very Fast! to Stock Market Financial Technical Analysis Python

dev 34 Dec 27, 2022
This is an open source python repository for various python tests

Welcome to Py-tests This is an open source python repository for various python tests. This is in response to the hacktoberfest2021 challenge. It is a

Yada Martins Tisan 3 Oct 31, 2021
Composable transformations of Python+NumPy programsComposable transformations of Python+NumPy programs

Chex Chex is a library of utilities for helping to write reliable JAX code. This includes utils to help: Instrument your code (e.g. assertions) Debug

DeepMind 506 Jan 8, 2023
Automatic self-diagnosis program (python required)Automatic self-diagnosis program (python required)

auto-self-checker 자동으로 자가진단 해주는 프로그램(python 필요) 중요 이 프로그램이 실행될때에는 절대로 마우스포인터를 움직이거나 키보드를 건드리면 안된다(화면인식, 마우스포인터로 직접 클릭) 사용법 프로그램을 구동할 폴더 내의 cmd창에서 pip

null 1 Dec 30, 2021
POPPY (Physical Optics Propagation in Python) is a Python package that simulates physical optical propagation including diffraction

POPPY: Physical Optics Propagation in Python POPPY (Physical Optics Propagation in Python) is a Python package that simulates physical optical propaga

Space Telescope Science Institute 132 Dec 15, 2022