Coder Social home page Coder Social logo

linru0 / masr Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yeyupiaoling/masr

0.0 0.0 0.0 6.4 MB

Pytorch实现的流式与非流式的自动语音识别框架,同时兼容在线和离线识别,目前支持Conformer、Squeezeformer、DeepSpeech2模型,支持多种数据增强方法。

License: Apache License 2.0

JavaScript 1.49% Python 97.15% CSS 0.31% HTML 1.05%

masr's Introduction

python version GitHub forks GitHub Repo stars GitHub 支持系统

MASR流式与非流式语音识别项目

MASR是一款基于Pytorch实现的自动语音识别框架,MASR全称是神奇的自动语音识别框架(Magical Automatic Speech Recognition),当前为V2版本,如果想使用V1版本,请在这个分支r1.x。MASR致力于简单,实用的语音识别项目。可部署在服务器,Nvidia Jetson设备,未来还计划支持Android等移动设备。

欢迎大家扫码入知识星球或者QQ群讨论,知识星球里面提供项目的模型文件和博主其他相关项目的模型文件,也包括其他一些资源。

知识星球 QQ群

本项目使用的环境:

  • Anaconda 3
  • Python 3.8
  • Pytorch 1.13.1
  • Windows 10 or Ubuntu 18.04

项目快速了解

  1. 本项目支持流式识别模型deepspeech2conformersqueezeformerefficient_conformer,每个模型都支持流式识别和非流式识别,在配置文件中streaming参数设置。
  2. 本项目支持两种解码器,分别是集束搜索解码器ctc_beam_search和贪心解码器ctc_greedy,集束搜索解码器ctc_beam_search准确率更高。
  3. 下面提供了一系列预训练模型的下载,下载预训练模型之后,需要把全部文件复制到项目根目录,并执行导出模型才可以使用语音识别。

更新记录

  • 2023.01.28: 调整配置文件结构,支持efficient_conformer模型。
  • 2022.11: 正式发布最终级的V2版本。

视频讲解

这个是PPSAR的视频教程,项目是通用的,可以参考使用。

在线使用

- 在线使用Dome

快速使用

这里介绍如何使用MASR快速进行语音识别,前提是要安装MASR,文档请看快速安装。执行过程不需要手动下载模型,全部自动完成。

  1. 短语音识别
from masr.predict import MASRPredictor

predictor = MASRPredictor(model_tag='conformer_streaming_fbank_aishell')

wav_path = 'dataset/test.wav'
result = predictor.predict(audio_data=wav_path, use_pun=False)
score, text = result['score'], result['text']
print(f"识别结果: {text}, 得分: {int(score)}")
  1. 长语音识别
from masr.predict import MASRPredictor

predictor = MASRPredictor(model_tag='conformer_streaming_fbank_aishell')

wav_path = 'dataset/test_long.wav'
result = predictor.predict_long(audio_data=wav_path, use_pun=False)
score, text = result['score'], result['text']
print(f"识别结果: {text}, 得分: {score}")
  1. 模拟流式识别
import time
import wave

from masr.predict import MASRPredictor

predictor = MASRPredictor(model_tag='conformer_streaming_fbank_aishell')

# 识别间隔时间
interval_time = 0.5
CHUNK = int(16000 * interval_time)
# 读取数据
wav_path = 'dataset/test.wav'
wf = wave.open(wav_path, 'rb')
data = wf.readframes(CHUNK)
# 播放
while data != b'':
    start = time.time()
    d = wf.readframes(CHUNK)
    result = predictor.predict_stream(audio_data=data, use_pun=False, is_end=d == b'')
    data = d
    if result is None: continue
    score, text = result['score'], result['text']
    print(f"【实时结果】:消耗时间:{int((time.time() - start) * 1000)}ms, 识别结果: {text}, 得分: {int(score)}")
# 重置流式识别
predictor.reset_stream()

模型下载

  1. WenetSpeech (10000小时) 的预训练模型列表:
使用模型 是否为流式 预处理方式 语言 测试集字错率 下载地址
conformer True fbank 普通话
  1. WenetSpeech (10000小时)+中文语音数据集 (3000+小时) 的预训练模型列表:
使用模型 是否为流式 预处理方式 语言 测试集字错率 下载地址
conformere True fbank 普通话 0.03179(aishell_test)
0.16722(test_net)
0.20317(test_meeting)
加入知识星球获取
  1. AIShell (179小时) 的预训练模型列表:
使用模型 是否为流式 预处理方式 语言 测试集字错率 下载地址
squeezeformer True fbank 普通话 0.04137 加入知识星球获取
conformer True fbank 普通话 0.04491 加入知识星球获取
efficient_conformer True fbank 普通话 0.04073 加入知识星球获取
deepspeech2 True fbank 普通话 0.06907 加入知识星球获取
  1. Librispeech (960小时) 的预训练模型列表:
使用模型 是否为流式 预处理方式 语言 测试集词错率 下载地址
squeezeformer True fbank 英文 0.09715 加入知识星球获取
conformer True fbank 英文 0.09265 加入知识星球获取
efficient_conformer True fbank 英文 加入知识星球获取
deepspeech2 True fbank 英文 0.19423 加入知识星球获取

说明:

  1. 这里字错率或者词错率是使用eval.py程序并使用集束搜索解码ctc_beam_search方法计算得到的。
  2. 没有提供预测模型,需要把全部文件复制到项目的根目录下,执行export_model.py导出预测模型。
  3. 由于算力不足,这里只提供了流式模型,但全部模型都支持流式和非流式的,在配置文件中streaming参数设置。

有问题欢迎提 issue 交流

文档教程

相关项目

打赏作者


打赏一块钱支持一下作者

打赏作者

参考资料

masr's People

Contributors

yeyupiaoling avatar moneypi avatar owhileo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.