Espnet ASR-an4 Dataset-Inference with quantization

本文档介绍了如何使用Espnet安装、运行ASR实验,特别是针对An4数据集。首先,从GitHub仓库下载并处理An4数据集。然后,跳过训练阶段,加载预训练模型进行推断。最后,展示了如何在运行时启用模型量化,以实现动态量化,并检查量化后的ASR模型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Espnet Installation

See here

An4 Dataset

  1. an4 dataset can not be download from CMU offical website, but we can access it from this github repo
  2. git clone https://github.com/kavuri/an4.git and delete .git dir from /an4. Then, compress /an4 to an4_sphere.tar.gz and put it into espnet/egs2/an4/asr1/downloads (you might need to create the /downloads dir)

ASR Inference Experiment with An4 Dataset

  1. find a pretrained model in here with keywords like espnet, asr, en, etc.
  2. cd espnet/egs2/an4/asr1 & ./run.sh --skip_train true --download_model <model-name>
    In which --skip_train true is to skip the trainning stage and --download_model <model-name> is to use the pretrained model you found in the last step.
    eg. ./run.sh --skip_train true --download_model espnet/Shinji_Watanabe_spgispeech_asr_train_asr_conformer6_n_fft512_hop_length256_raw_en_bpe5000_valid.acc.ave

Quantization

To enable model quantization

  1. vim espnet/espnet2/bin/asr_inference.py & add following codes in line 89

    dynamic_quantize = True
    if dynamic_quantize:
        # q_config = {torch.nn.Linear,torch.nn.LSTM,torch.nn.GRU}
        quantize_dtype = torch.qint8
        asr_model = torch.quantization.quantize_dynamic(asr_model, None, dtype=quantize_dtype)
    

    which enables dynamic quantization among the asr model

  2. you can also check the asr model in the runtime log by adding

    logging.info(f"ASR model: {asr_model}")
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值