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
GLODISMO: Gradient-Based Learning of Discrete Structured Measurement Operators for Signal Recovery

GLODISMO: Gradient-Based Learning of Discrete Structured Measurement Operators for Signal Recovery This is the code to the paper: Gradient-Based Learn

3 Feb 15, 2022
Code repository for our paper "Learning to Generate Scene Graph from Natural Language Supervision" in ICCV 2021

Scene Graph Generation from Natural Language Supervision This repository includes the Pytorch code for our paper "Learning to Generate Scene Graph fro

Yiwu Zhong 64 Dec 24, 2022
NICE-GAN — Official PyTorch Implementation Reusing Discriminators for Encoding: Towards Unsupervised Image-to-Image Translation

NICE-GAN-pytorch - Official PyTorch implementation of NICE-GAN: Reusing Discriminators for Encoding: Towards Unsupervised Image-to-Image Translation

Runfa Chen 208 Nov 25, 2022
Transferable Unrestricted Attacks, which won 1st place in CVPR’21 Security AI Challenger: Unrestricted Adversarial Attacks on ImageNet.

Transferable Unrestricted Adversarial Examples This is the PyTorch implementation of the Arxiv paper: Towards Transferable Unrestricted Adversarial Ex

equation 16 Dec 29, 2022
Official Pytorch implementation of the paper: "Locally Shifted Attention With Early Global Integration"

Locally-Shifted-Attention-With-Early-Global-Integration Pretrained models You can download all the models from here. Training Imagenet python -m torch

Shelly Sheynin 14 Apr 15, 2022
Pixel-Perfect Structure-from-Motion with Featuremetric Refinement (ICCV 2021, Oral)

Pixel-Perfect Structure-from-Motion (ICCV 2021 Oral) We introduce a framework that improves the accuracy of Structure-from-Motion by refining keypoint

Computer Vision and Geometry Lab 831 Dec 29, 2022
[IJCAI-2021] A benchmark of data-free knowledge distillation from paper "Contrastive Model Inversion for Data-Free Knowledge Distillation"

DataFree A benchmark of data-free knowledge distillation from paper "Contrastive Model Inversion for Data-Free Knowledge Distillation" Authors: Gongfa

ZJU-VIPA 47 Jan 09, 2023
Stock-Prediction - prediction of stock market movements using sentiment analysis and deep learning.

Stock-Prediction- In this project, we aim to enhance the prediction of stock market movements using sentiment analysis and deep learning. We divide th

5 Jan 25, 2022
Official PyTorch Implementation of Mask-aware IoU and maYOLACT Detector [BMVC2021]

The official implementation of Mask-aware IoU and maYOLACT detector. Our implementation is based on mmdetection. Mask-aware IoU for Anchor Assignment

Kemal Oksuz 46 Sep 29, 2022
TagLab: an image segmentation tool oriented to marine data analysis

TagLab: an image segmentation tool oriented to marine data analysis TagLab was created to support the activity of annotation and extraction of statist

Visual Computing Lab - ISTI - CNR 49 Dec 29, 2022
A Comparative Framework for Multimodal Recommender Systems

Cornac Cornac is a comparative framework for multimodal recommender systems. It focuses on making it convenient to work with models leveraging auxilia

Preferred.AI 671 Jan 03, 2023
E-RAFT: Dense Optical Flow from Event Cameras

E-RAFT: Dense Optical Flow from Event Cameras This is the code for the paper E-RAFT: Dense Optical Flow from Event Cameras by Mathias Gehrig, Mario Mi

Robotics and Perception Group 71 Dec 12, 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

157 Dec 26, 2022
Codes for the AAAI'22 paper "TransZero: Attribute-guided Transformer for Zero-Shot Learning"

TransZero [arXiv] This repository contains the testing code for the paper "TransZero: Attribute-guided Transformer for Zero-Shot Learning" accepted to

Shiming Chen 52 Jan 01, 2023
Implementation of Basic Machine Learning Algorithms on small datasets using Scikit Learn.

Basic Machine Learning Algorithms All the basic Machine Learning Algorithms are implemented in Python using libraries Acknowledgements Machine Learnin

Piyal Banik 47 Oct 16, 2022
LightHuBERT: Lightweight and Configurable Speech Representation Learning with Once-for-All Hidden-Unit BERT

LightHuBERT LightHuBERT: Lightweight and Configurable Speech Representation Learning with Once-for-All Hidden-Unit BERT | Github | Huggingface | SUPER

WangRui 46 Dec 29, 2022
Rasterize with the least efforts for researchers.

utils3d Rasterize and do image-based 3D transforms with the least efforts for researchers. Based on numpy and OpenGL. It could be helpful when you wan

Ruicheng Wang 8 Dec 15, 2022
MLOps will help you to understand how to build a Continuous Integration and Continuous Delivery pipeline for an ML/AI project.

page_type languages products description sample python azure azure-machine-learning-service azure-devops Code which demonstrates how to set up and ope

1 Nov 01, 2021
K Closest Points and Maximum Clique Pruning for Efficient and Effective 3D Laser Scan Matching (To appear in RA-L 2022)

KCP The official implementation of KCP: k Closest Points and Maximum Clique Pruning for Efficient and Effective 3D Laser Scan Matching, accepted for p

Yu-Kai Lin 109 Dec 14, 2022
ViSD4SA, a Vietnamese Span Detection for Aspect-based sentiment analysis dataset

UIT-ViSD4SA PACLIC 35 General Introduction This repository contains the data of the paper: Span Detection for Vietnamese Aspect-Based Sentiment Analys

Nguyễn Thị Thanh Kim 5 Nov 13, 2022