Code Monkey home page Code Monkey logo

tensorflowasr's Introduction

TensorflowASR

python tensorflow

基于Conformer的Tensorflow 2版本的端到端语音识别模型,并且CPU的RTF(实时率)在0.1左右

当前branch为V2版本,为CTC+translate结构

欢迎使用并反馈bug

旧版请看 V1版本

实现功能

  • VAD+降噪
  • 在线流式识别/离线识别
  • 标点恢复

其它项目

TTS:https://github.com/Z-yq/TensorflowTTS

NLU: -

BOT: -

Mel Layer

参照librosa库,用TF2实现了语音频谱特征提取的层。

或者可以使用更小参数量的Leaf

使用:

  • am_data.yml
    mel_layer_type: Melspectrogram #Spectrogram/leaf
    trainable_kernel: True #support train model,not recommend
    

Cpp Inference

已经更新基于ONNX的CPP项目,

详见 CppInference ONNX

Python Inference

基于ONNX的python inference方案,详情见python inference

Streaming Conformer

现在支持流式的Conformer结构啦,同epoch训练下,和全局conformer的CER仅差0.8%。

streaming_conformer

Pretrained Model

所有结果测试于 AISHELL TEST 数据集.

RTF(实时率) 测试于CPU单核解码任务。

AM:

Model Name Mel layer(USE/TRAIN) link code train data phoneme CER(%) Params Size RTF
ConformerCTC(S) True/False pan.baidu.com/s/1k6miY1yNgLrT0cB-xsqqag 8s53 aishell-1(50 epochs) 6.4 10M 0.056
StreamingConformerCTC True/False pan.baidu.com/s/1Rc0x7LOiExaAC0GNhURkHw zwh9 aishell-1(50 epochs) 7.2 15M 0.08

VAD:

Model Name link code train data params size RTF
8k_online_vad pan.baidu.com/s/1ag9VwTxIqW4C2AgF-6nIgg ofc9 openslr开源数据 80K 0.0001

Punc:

Model Name link code train data acc params size RTF
PuncModel pan.baidu.com/s/1gtvRKYIE2cAbfiqBn9bhaw 515t NLP开源数据 95% 600K 0.0001

使用:

test_asr.py 中将model转成onnx文件放入pythonInference中

Community

欢迎加入,讨论和分享问题。 群1已满。

What's New?

最新更新

  • 🥇 [2021.08.19]更改了Streaming Conformer结构,舍弃了之前的LSTM结构以提升训练速度,目前已经验证推举配置的训练结果只和全局的conformer相差1%左右。

Supported Structure

  • CTC+Streaming

Supported Models

  • Conformer
  • StreamingConformer

Requirements

  • Python 3.6+
  • Tensorflow 2.5+: pip install tensorflow-gpu
  • librosa
  • pypinyin if you need use the default phoneme
  • keras-bert
  • addons For LAS structure,pip install tensorflow-addons
  • tqdm
  • tf2onnx

Usage

  1. 准备train_list和test_list.

    asr_train_list 格式,其中'\t'为tap:

    file_path1 \t text1
    file_path2 \t text2
    ……
    

    例如:

    /opt/data/test.wav	这个是一个例子
    

以下为vad和标点恢复的训练数据准备格式(非必需):

vad_train_list 格式:

wav_path1
wav_path2
……

例如:

/opt/data/test.wav

punc_train_list格式:

 text1
 text2
 ……

同LM的格式,每行的text包含标点,目前标点只支持每个字后跟一个标点,连续的标点视为无效。

比如:

这是:一个例子哦。 √(正确格式)

这是:“一个例子哦”。 ×(错误格式)

这是:一个例子哦“。 ×(错误格式)

  1. 下载bert的预训练模型,用于标点恢复模型的辅助训练,如果你不需要标点恢复可以跳过:

     https://pan.baidu.com/s/1_HDAhfGZfNhXS-cYoLQucA extraction code: 4hsa
    
  2. 修改配置文件 am_data.yml (./asr/configs)来设置一些训练的选项,以及修改model yaml(如:./asr/configs/conformer.yml) 里的name参数来选择模型结构。

  3. 然后执行命令:

    python train_asr.py --data_config ./asr/configs/am_data.yml --model_config ./asr/configs/ConformerS.yml
  4. 想要测试时,可以参考 ./test_asr.py 里写的demo,当然你可以修改 stt 方法来适应你的需求:

     python ./test_asr.py  

也可以使用Tester 来大批量测试数据验证你的模型性能:

执行:

python eval_am.py --data_config ./asr/configs/am_data.yml --model_config ./asr/configs/ConformerS.yml

该脚本将展示 SER/CER/DEL/INS/SUB 几项指标

6.训练VAD或者标点恢复模型,请参照以上步骤。

Tips

如果你想用你自己的音素,需要对应 am_dataloader.py 里的转换方法。

def init_text_to_vocab(self):#keep the name
    
    def text_to_vocab_func(txt):
        return your_convert_function

    self.text_to_vocab = text_to_vocab_func #here self.text_to_vocab is a function,not a call

不要忘记你的音素列表用 <S></S> 打头,e.g:

    <S>
    </S>
    de
    shì
    ……

References

参考了以下优秀项目:

https://github.com/usimarit/TiramisuASR

https://github.com/noahchalifour/warp-transducer

https://github.com/PaddlePaddle/DeepSpeech

https://github.com/baidu-research/warp-ctc

Licence

允许并感谢您使用本项目进行学术研究、商业产品生产等,但禁止将本项目作为商品进行交易。

Overall, Almost models here are licensed under the Apache 2.0 for all countries in the world.

Allow and thank you for using this project for academic research, commercial product production, allowing unrestricted commercial and non-commercial use alike.

However, it is prohibited to trade this project as a commodity.

tensorflowasr's People

Contributors

z-yq 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.