【语音处理】s3prl ASR调试记录

文章目录

安装

  1. 环境准备:python 3.10 (2024年4月目前不支持3.10之上的版本),sox,torchaudio==2.0.2(如果高于此版本会报错)
conda create -n s3prl python==3.10
pip install torchaudio==2.0.2

sox的安装参考了网上了不需要sudo的教程

  1. 安装代码
git clone https://github.com/s3prl/s3prl.git
cd s3prl
pip install -e .

模型训练

  1. 数据准备

    • 按照要求下载Librispeech
    • 修改config文件downstream/asr/config.yaml中的数据根目录
    downstream_expert:
        datarc:
            libri_root: "root directory of LibriSpeech"
    
    • 运行数据准备代码
python3 preprocess/generate_len_for_bucket.py -i "/my/LibriSpeech" -o data/librispeech -a .flac --n_jobs 4
         0 : train-clean-100
         1 : train-clean-360
         2 : train-other-500
         3 : dev-clean
         4 : dev-other
         5 : test-clean
         6 : test-other
Please enter the index of splits you wish to use preprocess. (seperate with space): 0 3 5

Preprocessing data in: train-clean-100, 28539 audio files found.
Extracting audio length...
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 28539/28539 [00:57<00:00, 500.28it/s]

Preprocessing data in: dev-clean, 2703 audio files found.
Extracting audio length...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2703/2703 [00:09<00:00, 282.02it/s]

Preprocessing data in: test-clean, 2620 audio files found.
Extracting audio length...
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2620/2620 [00:09<00:00, 270.78it/s]
All done, saved at data/librispeech/len_for_bucket exit.
  1. 模型训练
python3 run_downstream.py -n wav2vec2 -m train -u wav2vec2 -d asr -s hidden_states

其中

  • -u指定预训练模型,此处指定wav2vec2
  • -d指定任务asr
  • -n指定输出目录名称
  • -s选择使用的特征,hidden_states计算所有隐藏层的加权和
  1. 模型测试
python3 run_downstream.py -m evaluate -t "test-clean" -e [ckpt]

在LibriSpeech test-clean上的测试结果:
test-clean loss: 0.13725118339061737
test-clean uer: 1.8757698398733063
test-clean wer: 6.626597687157639

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值