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
Revitalizing CNN Attention via Transformers in Self-Supervised Visual Representation Learning

Revitalizing CNN Attention via Transformers in Self-Supervised Visual Representation Learning

ChongjianGE 89 Dec 02, 2022
Sleep staging from ECG, assisted with EEG

Sleep_Staging_Knowledge Distillation This codebase implements knowledge distillation approach for ECG based sleep staging assisted by EEG based sleep

2 Dec 12, 2022
This is the repository for the AAAI 21 paper [Contrastive and Generative Graph Convolutional Networks for Graph-based Semi-Supervised Learning].

CG3 This is the repository for the AAAI 21 paper [Contrastive and Generative Graph Convolutional Networks for Graph-based Semi-Supervised Learning]. R

12 Oct 28, 2022
From this paper "SESNet: A Semantically Enhanced Siamese Network for Remote Sensing Change Detection"

SESNet for remote sensing image change detection It is the implementation of the paper: "SESNet: A Semantically Enhanced Siamese Network for Remote Se

1 May 24, 2022
PyMove is a Python library to simplify queries and visualization of trajectories and other spatial-temporal data

Use PyMove and go much further Information Package Status License Python Version Platforms Build Status PyPi version PyPi Downloads Conda version Cond

Insight Data Science Lab 64 Nov 15, 2022
Implementation of E(n)-Transformer, which extends the ideas of Welling's E(n)-Equivariant Graph Neural Network to attention

E(n)-Equivariant Transformer (wip) Implementation of E(n)-Equivariant Transformer, which extends the ideas from Welling's E(n)-Equivariant G

Phil Wang 132 Jan 02, 2023
Continuous Diffusion Graph Neural Network

We present Graph Neural Diffusion (GRAND) that approaches deep learning on graphs as a continuous diffusion process and treats Graph Neural Networks (GNNs) as discretisations of an underlying PDE.

Twitter Research 227 Jan 05, 2023
This repo generates the training data and the model for Morpheus-Deblend

Morpheus-Deblend This repo generates the training data and the model for Morpheus-Deblend. This is the active development repo for the project and as

Ryan Hausen 2 Apr 18, 2022
OpenPose: Real-time multi-person keypoint detection library for body, face, hands, and foot estimation

Build Type Linux MacOS Windows Build Status OpenPose has represented the first real-time multi-person system to jointly detect human body, hand, facia

25.7k Jan 09, 2023
Implementation of a memory efficient multi-head attention as proposed in the paper, "Self-attention Does Not Need O(n²) Memory"

Memory Efficient Attention Pytorch Implementation of a memory efficient multi-head attention as proposed in the paper, Self-attention Does Not Need O(

Phil Wang 180 Jan 05, 2023
Fully Convlutional Neural Networks for state-of-the-art time series classification

Deep Learning for Time Series Classification As the simplest type of time series data, univariate time series provides a reasonably good starting poin

Stephen 572 Dec 23, 2022
The source code of CVPR17 'Generative Face Completion'.

GenerativeFaceCompletion Matcaffe implementation of our CVPR17 paper on face completion. In each panel from left to right: original face, masked input

Yijun Li 313 Oct 18, 2022
Learning Saliency Propagation for Semi-supervised Instance Segmentation

Learning Saliency Propagation for Semi-supervised Instance Segmentation PyTorch Implementation This repository contains: the PyTorch implementation of

Berkeley DeepDrive 68 Oct 18, 2022
JFB: Jacobian-Free Backpropagation for Implicit Models

JFB: Jacobian-Free Backpropagation for Implicit Models

Typal Research 28 Dec 11, 2022
Keras Image Embeddings using Contrastive Loss

Image to Embedding projection in vector space. Implementation in keras and tensorflow of batch all triplet loss for one-shot/few-shot learning.

Shravan Anand K 5 Mar 21, 2022
Softlearning is a reinforcement learning framework for training maximum entropy policies in continuous domains. Includes the official implementation of the Soft Actor-Critic algorithm.

Softlearning Softlearning is a deep reinforcement learning toolbox for training maximum entropy policies in continuous domains. The implementation is

Robotic AI & Learning Lab Berkeley 997 Dec 30, 2022
Demo project for real time anomaly detection using kafka and python

kafkaml-anomaly-detection Project for real time anomaly detection using kafka and python It's assumed that zookeeper and kafka are running in the loca

Rodrigo Arenas 36 Dec 12, 2022
Official code release for "GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis"

GRAF This repository contains official code for the paper GRAF: Generative Radiance Fields for 3D-Aware Image Synthesis. You can find detailed usage i

349 Dec 29, 2022
Trustworthy AI related projects

Trustworthy AI This repository aims to include trustworthy AI related projects from Huawei Noah's Ark Lab. Current projects include: Causal Structure

HUAWEI Noah's Ark Lab 589 Dec 30, 2022
Deep Learning for Time Series Forecasting.

nixtlats:Deep Learning for Time Series Forecasting [nikstla] (noun, nahuatl) Period of time. State-of-the-art time series forecasting for pytorch. Nix

Nixtla 5 Dec 06, 2022