
ที่เก็บนี้มีชุดเครื่องมือ Pytorch-Kaldi รุ่นสุดท้าย (Pytorch-Kaldi-V1.0) หากต้องการดูเวอร์ชันก่อนหน้า (Pytorch-Kaldi-V0.1) คลิกที่นี่
หากคุณใช้รหัสนี้หรือบางส่วนโปรดอ้างอิงกระดาษต่อไปนี้:
M. Ravanelli, T. Parcollet, Y. Bengio, "The Pytorch-Kaldi Speech Recognition Toolkit", Arxiv
@inproceedings{pytorch-kaldi,
title = {The PyTorch-Kaldi Speech Recognition Toolkit},
author = {M. Ravanelli and T. Parcollet and Y. Bengio},
booktitle = {In Proc. of ICASSP},
year = {2019}
}
Toolkit ได้รับการปล่อยตัวภายใต้ ใบอนุญาต Creative Commons Attribution 4.0 International คุณสามารถคัดลอกแจกจ่ายแก้ไขรหัสสำหรับการวิจัยวัตถุประสงค์เชิงพาณิชย์และไม่ใช่เชิงพาณิชย์ เราขอเฉพาะการอ้างอิงบทความที่อ้างอิงข้างต้น
เพื่อปรับปรุงความโปร่งใสและความสามารถในการทำซ้ำของผลลัพธ์การรู้จำเสียงพูดเราให้ความเป็นไปได้ที่ผู้ใช้ในการปล่อยโมเดล Pytorch-Kaldi ภายในที่เก็บนี้ อย่าลังเลที่จะติดต่อเรา (หรือทำคำขอดึง) สำหรับเรื่องนั้น ยิ่งกว่านั้นหากกระดาษของคุณใช้ Pytorch-Kaldi ก็เป็นไปได้ที่จะโฆษณาในที่เก็บนี้
ดูวิดีโอเบื้องต้นสั้น ๆ เกี่ยวกับชุดเครื่องมือ Pytorch-Kaldi
เรายินดีที่จะประกาศว่าโครงการ Beechbrain (https://speechbrain.github.io/) ตอนนี้เป็นสาธารณะ! เราขอแนะนำให้ผู้ใช้โยกย้ายไปยัง Beechbrain มันเป็นโครงการที่ดีกว่ามากซึ่งสนับสนุนงานการประมวลผลคำพูดหลายอย่างเช่นการรู้จำเสียงพูดการจดจำผู้พูด, SLU, การเพิ่มประสิทธิภาพการพูด, การแยกคำพูด, การประมวลผลสัญญาณหลายไมโครโฟนและอื่น ๆ อีกมากมาย
เป้าหมายคือการพัฒนาชุดเครื่องมือเครื่องมือ เดียว ที่ยืดหยุ่น และ ใช้งานง่าย ซึ่งสามารถใช้ในการพัฒนาระบบการพูดที่ล้ำสมัยสำหรับการรู้จำเสียงพูดได้อย่างง่ายดาย
โครงการจะนำโดย MILA และได้รับการสนับสนุนจาก Samsung, Nvidia, Dolby Speechbrain จะได้รับประโยชน์จากการทำงานร่วมกันและความเชี่ยวชาญของ บริษัท อื่น ๆ เช่น Facebook/Pytorch, Ibmresearch, Fluentai
เรากำลังมองหาผู้ทำงานร่วมกันอย่างแข็งขัน อย่าลังเลที่จะติดต่อเราได้ที่ [email protected] หากคุณสนใจที่จะทำงานร่วมกัน
ต้องขอบคุณผู้สนับสนุนของเราเรายังสามารถจ้างฝึกงานที่ทำงานที่ MILA ในโครงการ Beechbrain ผู้สมัครในอุดมคติคือนักศึกษาปริญญาเอกที่มีประสบการณ์เกี่ยวกับ Pytorch และ Technologies Speech (ส่ง CV ของคุณไปที่ [email protected])
การพัฒนาของ Beechbrain จะต้องใช้เวลาหลายเดือนก่อนที่จะมีที่เก็บที่ทำงาน ในขณะเดียวกันเราจะให้การสนับสนุนโครงการ Pytorch-Kaldi ต่อไป
คอยติดตาม!
โครงการ Pytorch-Kaldi มีจุดมุ่งหมายเพื่อเชื่อมช่องว่างระหว่าง Kaldi และชุดเครื่องมือ Pytorch พยายามที่จะสืบทอดประสิทธิภาพของ Kaldi และความยืดหยุ่นของ Pytorch Pytorch-Kaldi ไม่เพียง แต่เป็นอินเทอร์เฟซที่เรียบง่ายระหว่างชุดเครื่องมือเหล่านี้เท่านั้น ตัวอย่างเช่นรหัสได้รับการออกแบบมาโดยเฉพาะเพื่อใช้โมเดลอะคูสติกที่ผู้ใช้ที่กำหนดไว้ตามธรรมชาติ เป็นทางเลือกผู้ใช้สามารถใช้ประโยชน์จากเครือข่ายประสาทที่ใช้ล่วงหน้าหลายแห่งซึ่งสามารถปรับแต่งได้โดยใช้ไฟล์การกำหนดค่าที่ใช้งานง่าย Pytorch-Kaldi รองรับคุณลักษณะหลายอย่างและสตรีมฉลากรวมถึงการรวมกันของเครือข่ายประสาททำให้สามารถใช้สถาปัตยกรรมประสาทที่ซับซ้อนได้ Toolkit ได้รับการเผยแพร่ต่อสาธารณะพร้อมกับเอกสารประกอบที่หลากหลายและได้รับการออกแบบมาเพื่อทำงานอย่างถูกต้องในพื้นที่หรือในกลุ่ม HPC
คุณสมบัติบางอย่างของชุดเครื่องมือ Pytorch-Kaldi รุ่นใหม่:
export KALDI_ROOT=/home/mirco/kaldi-trunk
PATH=$PATH:$KALDI_ROOT/tools/openfst
PATH=$PATH:$KALDI_ROOT/src/featbin
PATH=$PATH:$KALDI_ROOT/src/gmmbin
PATH=$PATH:$KALDI_ROOT/src/bin
PATH=$PATH:$KALDI_ROOT//src/nnetbin
export PATH
อย่าลืมเปลี่ยนตัวแปร kaldi_root โดยใช้เส้นทางของคุณ เป็นการทดสอบครั้งแรกเพื่อตรวจสอบการติดตั้งให้เปิดเชลล์ทุบตีให้พิมพ์ "Copy-Feats" หรือ "HMM-INFO" และตรวจสอบให้แน่ใจว่าไม่มีข้อผิดพลาดปรากฏขึ้น
หากยังไม่เสร็จให้ติดตั้ง pytorch (http://pytorch.org/) เราทดสอบรหัสของเราใน Pytorch 1.0 และ Pytorch 0.4 Pytorch รุ่นเก่ามีแนวโน้มที่จะเพิ่มข้อผิดพลาด ในการตรวจสอบการติดตั้งของคุณให้พิมพ์“ Python” และเมื่อป้อนลงในคอนโซลให้พิมพ์“ นำเข้าคบเพลิง” และตรวจสอบให้แน่ใจว่าไม่มีข้อผิดพลาดปรากฏขึ้น
เราขอแนะนำให้เรียกใช้รหัสบนเครื่อง GPU ตรวจสอบให้แน่ใจว่าห้องสมุด CUDA (https://developer.nvidia.com/cuda-downloads) ได้รับการติดตั้งและทำงานได้อย่างถูกต้อง เราทดสอบระบบของเราใน CUDA 9.0, 9.1 และ 8.0 ตรวจสอบให้แน่ใจว่ามีการติดตั้ง Python (รหัสถูกทดสอบด้วย Python 2.7 และ Python 3.7) แม้ว่าจะไม่ได้รับคำสั่ง แต่เราแนะนำให้ใช้ Anaconda (https://anaconda.org/anaconda/python)
19 ก.พ. 2019: อัปเดต:
batch_size_train = 128*12 | 64*10 | 32*2
บรรทัดด้านบนหมายถึง: ทำ 12 ยุคที่มี 128 แบตช์, 10 Epochs ที่มี 64 แบตช์และ 2 ยุคที่มี 32 แบทช์ พิธีการที่คล้ายกันสามารถใช้สำหรับอัตราการเรียนรู้และการตั้งเวลาออกกลางคัน ดูส่วนนี้สำหรับข้อมูลเพิ่มเติม
5 ก.พ. 2019: อัปเดต:
หมายเหตุเกี่ยวกับเวอร์ชันถัดไป: ในเวอร์ชันถัดไปเราวางแผนที่จะขยายฟังก์ชันการทำงานของชุดเครื่องมือของเราต่อไปสนับสนุนรูปแบบและฟีเจอร์เพิ่มเติม เป้าหมายคือการทำให้ชุดเครื่องมือของเราเหมาะสำหรับงานอื่น ๆ ที่เกี่ยวข้องกับการพูดเช่นการรู้จำเสียงพูดแบบ end-to-end การระบุผู้บรรยายการระบุคำหลักการแยกคำพูดการตรวจจับกิจกรรมการพูดการปรับปรุงเสียงพูด ฯลฯ หากคุณต้องการเสนอฟังก์ชั่นใหม่ ๆ
ในการติดตั้ง pytorch-kaldi ทำตามขั้นตอนต่อไปนี้:
git clone https://github.com/mravanelli/pytorch-kaldi
pip install -r requirements.txt
ในต่อไปนี้เรามีการสอนสั้น ๆ ของชุดเครื่องมือ Pytorch-Kaldi ตามชุดข้อมูล Timit ยอดนิยม
ตรวจสอบให้แน่ใจว่าคุณมีชุดข้อมูล Timit ถ้าไม่สามารถดาวน์โหลดได้จากเว็บไซต์ LDC (https://catalog.ldc.upenn.edu/ldc93s1)
ตรวจสอบให้แน่ใจว่าการติดตั้ง Kaldi และ Pytorch นั้นใช้ได้ดี ตรวจสอบให้แน่ใจว่าเส้นทาง Kaldi ของคุณกำลังทำงานอยู่ (คุณควรเพิ่มเส้นทาง Kaldi ลงใน. BASHRC ตามที่รายงานในส่วน "ข้อกำหนดเบื้องต้น") ตัวอย่างเช่นพิมพ์ "copy-feats" และ "hmm-info" และตรวจสอบให้แน่ใจว่าไม่มีข้อผิดพลาดปรากฏขึ้น
เรียกใช้พื้นฐาน Kaldi S5 ของ Timit ขั้นตอนนี้จำเป็นต้องคำนวณคุณสมบัติและฉลากในภายหลังที่ใช้ในการฝึกอบรมเครือข่ายประสาท Pytorch เราขอแนะนำให้ใช้สูตร Full Timit S5 (รวมถึงการฝึกอบรม DNN):
cd kaldi/egs/timit/s5
./run.sh
./local/nnet/run_dnn.sh
วิธีนี้ไฟล์ที่จำเป็นทั้งหมดถูกสร้างขึ้นและผู้ใช้สามารถเปรียบเทียบผลลัพธ์ที่ได้จาก Kaldi โดยตรงกับที่ได้มาจากชุดเครื่องมือของเรา
steps/align_fmllr.sh --nj 4 data/dev data/lang exp/tri3 exp/tri3_ali_dev
steps/align_fmllr.sh --nj 4 data/test data/lang exp/tri3 exp/tri3_ali_test
หากคุณต้องการใช้การจัดตำแหน่ง DNN (ตามที่แนะนำ) ให้พิมพ์:
steps/nnet/align.sh --nj 4 data-fmllr-tri3/train data/lang exp/dnn4_pretrain-dbn_dnn exp/dnn4_pretrain-dbn_dnn_ali
steps/nnet/align.sh --nj 4 data-fmllr-tri3/dev data/lang exp/dnn4_pretrain-dbn_dnn exp/dnn4_pretrain-dbn_dnn_ali_dev
steps/nnet/align.sh --nj 4 data-fmllr-tri3/test data/lang exp/dnn4_pretrain-dbn_dnn exp/dnn4_pretrain-dbn_dnn_ali_test
เราเริ่มต้นบทช่วยสอนนี้ด้วยเครือข่าย MLP ที่ง่ายมากที่ผ่านการฝึกอบรมเกี่ยวกับคุณสมบัติ MFCC ก่อนที่จะเปิดตัวการทดสอบลองดูที่ไฟล์กำหนดค่า CFG/TIMIT_BASELINES/TIMIT_MLP_MFCC_BASIC.CFG ดูคำอธิบายของไฟล์การกำหนดค่าสำหรับคำอธิบายโดยละเอียดของฟิลด์ทั้งหมด
เปลี่ยนไฟล์กำหนดค่าตามเส้นทางของคุณ โดยเฉพาะอย่างยิ่ง:
เพื่อหลีกเลี่ยงข้อผิดพลาดตรวจสอบให้แน่ใจว่าเส้นทางทั้งหมดในไฟล์ CFG มีอยู่ โปรดหลีกเลี่ยงการใช้เส้นทางที่มีตัวแปรทุบตีเนื่องจากเส้นทางถูกอ่านอย่างแท้จริงและไม่ได้ขยายโดยอัตโนมัติ (เช่นใช้/บ้าน/mirco/kaldi-trunk/egs/timit/s5/exp/dnn4_pretrain-dbn_dnn_ali แทนที่จะเป็น $ kaldi_root/egs
python run_exp.py cfg/TIMIT_baselines/TIMIT_MLP_mfcc_basic.cfg
สคริปต์นี้เริ่มต้นการทดลอง ASR เต็มรูปแบบและดำเนินการฝึกอบรมการตรวจสอบความถูกต้องไปข้างหน้าและขั้นตอนการถอดรหัส แถบความคืบหน้าแสดงวิวัฒนาการของขั้นตอนทั้งหมดดังกล่าว สคริปต์ run_exp.py สร้างไฟล์ต่อไปนี้อย่างต่อเนื่องในไดเรกทอรีเอาต์พุต:
โปรดทราบว่าคุณสามารถหยุดการทดลองได้ตลอดเวลา หากคุณเรียกใช้สคริปต์อีกครั้งมันจะเริ่มต้นจากการประมวลผลชิ้นล่าสุดโดยอัตโนมัติ การฝึกอบรมอาจใช้เวลาสองสามชั่วโมงขึ้นอยู่กับ GPU ที่มีอยู่ โปรดทราบว่าหากคุณต้องการเปลี่ยนพารามิเตอร์บางอย่างของไฟล์การกำหนดค่า (เช่น n_chunks =, fea_lst =, batch_size_train =, .. ) คุณต้องระบุโฟลเดอร์เอาต์พุตที่แตกต่างกัน (output_folder =)
DEBUG: หากคุณพบข้อผิดพลาดบางอย่างเราขอแนะนำให้ทำการตรวจสอบต่อไปนี้:
ลองดูเอาท์พุทมาตรฐาน
หากไม่มีประโยชน์ลองดูที่ไฟล์ log.log
ลองดูฟังก์ชั่น run_nn ลงใน Core.py Library เพิ่มงานพิมพ์บางส่วนในส่วนต่าง ๆ ของฟังก์ชั่นเพื่อแยกปัญหาและหาปัญหา
ในตอนท้ายของการฝึกอบรมอัตราความผิดพลาดของโทรศัพท์ (ต่อ%) จะถูกผนวกเข้ากับไฟล์ Res.Res หากต้องการดูรายละเอียดเพิ่มเติมเกี่ยวกับผลการถอดรหัสคุณสามารถไปที่ "Decoding_Test" ในโฟลเดอร์เอาท์พุทและดูไฟล์ต่าง ๆ ที่สร้างขึ้น สำหรับตัวอย่างเฉพาะนี้เราได้รับไฟล์ res.res ต่อไปนี้:
ep=000 tr=['TIMIT_tr'] loss=3.398 err=0.721 valid=TIMIT_dev loss=2.268 err=0.591 lr_architecture1=0.080000 time(s)=86
ep=001 tr=['TIMIT_tr'] loss=2.137 err=0.570 valid=TIMIT_dev loss=1.990 err=0.541 lr_architecture1=0.080000 time(s)=87
ep=002 tr=['TIMIT_tr'] loss=1.896 err=0.524 valid=TIMIT_dev loss=1.874 err=0.516 lr_architecture1=0.080000 time(s)=87
ep=003 tr=['TIMIT_tr'] loss=1.751 err=0.494 valid=TIMIT_dev loss=1.819 err=0.504 lr_architecture1=0.080000 time(s)=88
ep=004 tr=['TIMIT_tr'] loss=1.645 err=0.472 valid=TIMIT_dev loss=1.775 err=0.494 lr_architecture1=0.080000 time(s)=89
ep=005 tr=['TIMIT_tr'] loss=1.560 err=0.453 valid=TIMIT_dev loss=1.773 err=0.493 lr_architecture1=0.080000 time(s)=88
.........
ep=020 tr=['TIMIT_tr'] loss=0.968 err=0.304 valid=TIMIT_dev loss=1.648 err=0.446 lr_architecture1=0.002500 time(s)=89
ep=021 tr=['TIMIT_tr'] loss=0.965 err=0.304 valid=TIMIT_dev loss=1.649 err=0.446 lr_architecture1=0.002500 time(s)=90
ep=022 tr=['TIMIT_tr'] loss=0.960 err=0.302 valid=TIMIT_dev loss=1.652 err=0.447 lr_architecture1=0.001250 time(s)=88
ep=023 tr=['TIMIT_tr'] loss=0.959 err=0.301 valid=TIMIT_dev loss=1.651 err=0.446 lr_architecture1=0.000625 time(s)=88
%WER 18.1 | 192 7215 | 84.0 11.9 4.2 2.1 18.1 99.5 | -0.583 | /home/mirco/pytorch-kaldi-new/exp/TIMIT_MLP_basic5/decode_TIMIT_test_out_dnn1/score_6/ctm_39phn.filt.sys
ความสำเร็จต่อ (%) คือ 18.1% โปรดทราบว่าอาจมีความแปรปรวนบางอย่างในผลลัพธ์เนื่องจากการเริ่มต้นที่แตกต่างกันในเครื่องจักรที่แตกต่างกัน เราเชื่อว่าค่าเฉลี่ยประสิทธิภาพที่ได้จากเมล็ดเริ่มต้นที่แตกต่างกัน (เช่นเปลี่ยน เมล็ดพันธุ์ สนามในไฟล์กำหนดค่า) เป็นสิ่งสำคัญสำหรับเวลาเนื่องจากความแปรปรวนของประสิทธิภาพตามธรรมชาติอาจซ่อนหลักฐานการทดลองอย่างสมบูรณ์ เราสังเกตเห็นค่าเบี่ยงเบนมาตรฐานประมาณ 0.2% สำหรับการทดลองตามเวลา
หากคุณต้องการเปลี่ยนคุณสมบัติคุณต้องคำนวณพวกเขาด้วยชุดเครื่องมือ Kaldi ก่อน ในการคำนวณคุณสมบัติ fbank คุณต้องเปิด $ kaldi_root/egs/timit/s5/run.sh และคำนวณด้วยบรรทัดต่อไปนี้:
feadir=fbank
for x in train dev test; do
steps/make_fbank.sh --cmd "$train_cmd" --nj $feats_nj data/$x exp/make_fbank/$x $feadir
steps/compute_cmvn_stats.sh data/$x exp/make_fbank/$x $feadir
done
จากนั้นเปลี่ยนไฟล์กำหนดค่าดังกล่าวข้างต้นด้วยรายการคุณสมบัติใหม่ หากคุณได้เรียกใช้สูตร Kaldi Timit เต็มเวลาแล้วคุณสามารถค้นหาคุณสมบัติ FMLLR ได้โดยตรงใน $ Kaldi_Root/EGS/Timit/S5/Data-Fmllr-TRI3 หากคุณป้อนเครือข่ายประสาทด้วยคุณสมบัติดังกล่าวคุณควรคาดหวังการปรับปรุงประสิทธิภาพที่สำคัญเนื่องจากการปรับตัวของการปรับตัวของผู้พูด
ในโฟลเดอร์ timit_baseline เราเสนอตัวอย่างอื่น ๆ ของเส้นเขตแดนที่เป็นไปได้ ในทำนองเดียวกันกับตัวอย่างก่อนหน้านี้คุณสามารถเรียกใช้พวกเขาได้เพียงแค่พิมพ์:
python run_exp.py $cfg_file
มีตัวอย่างบางส่วนที่มีการเกิดซ้ำ (timit_rnn*, timit_lstm*, timit_gru*, timit_ligru*) และสถาปัตยกรรม CNN (timit_cnn*) นอกจากนี้เรายังเสนอโมเดลขั้นสูงเพิ่มเติม (timit_dnn_ligru_dnn_mfcc+fbank+fmllr.cfg) ที่เราใช้การผสมผสานระหว่างเครือข่าย neural ฟีดไปข้างหน้า โปรดทราบว่าไฟล์การกำหนดค่าหลังสอดคล้องกับสถาปัตยกรรมที่ดีที่สุดที่อธิบายไว้ในกระดาษอ้างอิง อย่างที่คุณเห็นจากไฟล์การกำหนดค่าที่กล่าวถึงข้างต้นเราปรับปรุงประสิทธิภาพ ASR โดยการรวมเทคนิคบางอย่างเช่นการทำให้เป็นมาตรฐาน monophone (เช่นเราประมาณการร่วมกันทั้งตามบริบทและเป้าหมายที่ไม่ขึ้นกับบริบท) ตารางต่อไปนี้รายงานผลลัพธ์ที่ได้จากการเรียกใช้ระบบหลัง (เฉลี่ยต่อ%):
| แบบอย่าง | MFCC | ฟ็อกแบงก์ | fmllr |
|---|---|---|---|
| Kaldi Dnn Baseline | - | - | 18.5 |
| MLP | 18.2 | 18.7 | 16.7 |
| rnn | 17.7 | 17.2 | 15.9 |
| ศรี | - | 16.6 | - |
| LSTM | 15.1 | 14.3 | 14.5 |
| กรุ | 16.0 | 15.2 | 14.9 |
| li-gru | 15.5 | 14.9 | 14.2 |
ผลลัพธ์แสดงให้เห็นว่าตามที่คาดไว้ FMLLR มีคุณสมบัติสูงกว่าค่าสัมประสิทธิ์ MFCCs และ FBANKS ด้วยกระบวนการปรับตัวของลำโพง โมเดลที่เกิดขึ้นซ้ำมีประสิทธิภาพสูงกว่า MLP ONE มาตรฐานโดยเฉพาะอย่างยิ่งเมื่อใช้สถาปัตยกรรม LSTM, GRU และ LI-GRU ซึ่งจัดการกับการไล่ระดับสีที่หายไปได้อย่างมีประสิทธิภาพผ่านประตูที่ทวีคูณ ผลลัพธ์ที่ดีที่สุด ต่อ = $ 14.2 $% คือโมเดล Li-GRU [2,3] ซึ่งขึ้นอยู่กับประตูเดียวและช่วยประหยัด 33% ของการคำนวณผ่าน GRU มาตรฐาน
ผลลัพธ์ที่ดีที่สุดได้มาจากสถาปัตยกรรมที่ซับซ้อนมากขึ้นซึ่งรวมคุณสมบัติ MFCC, FBANK และ FMLLR (ดู CFG/TIMI_BASELINES/TIMIT_MFCC_FBANK_FMLLR_LIGRU_BEST.CFG ) เพื่อความรู้ที่ดีที่สุดของเรา Per = 13.8% ที่ทำได้โดยระบบหลังจะให้ประสิทธิภาพที่ดีที่สุดที่เผยแพร่ในชุดทดสอบเวลา
หน่วยกำเริบอย่างง่าย (SRU) เป็นแบบจำลองการเกิดซ้ำที่มีประสิทธิภาพและขนานกันมาก ประสิทธิภาพของ ASR นั้นแย่กว่ารุ่น LSTM, GRU และ LIGRU มาตรฐาน แต่เร็วกว่าอย่างมาก SRU ถูกนำไปใช้ที่นี่และอธิบายไว้ในบทความต่อไปนี้:
T. Lei, Y. Zhang, Si Wang, H. Dai, Y. Artzi, "หน่วยกำเริบอย่างง่ายสำหรับการเกิดซ้ำที่สามารถเกิดขึ้นได้อย่างสูง
หากต้องการทำการทดลองกับรุ่นนี้ให้ใช้ไฟล์ config cfg/timit_baselines/timit_sru_fbank.cfg ก่อนที่คุณควรติดตั้งโมเดลโดยใช้ pip install sru และคุณควรไม่เขียนบท "นำเข้า SRU" ใน neural_networks.py
คุณสามารถเปรียบเทียบผลลัพธ์ของคุณโดยตรงกับเราโดยไปที่นี่ ในที่เก็บภายนอกนี้คุณสามารถค้นหาโฟลเดอร์ทั้งหมดที่มีไฟล์ที่สร้างขึ้น
ขั้นตอนในการเรียกใช้ pytorch-kaldi บนชุดข้อมูล librispeech นั้นคล้ายกับที่รายงานไว้ข้างต้นสำหรับ Timit บทช่วยสอนต่อไปนี้ขึ้นอยู่กับ ชุดย่อย 100H แต่สามารถขยายไปยังชุดข้อมูลเต็มรูปแบบได้อย่างง่ายดาย (960H)
mkdir exp/tri4b/decode_tgsmall_train_clean_100 && cp exp/tri4b/trans.* exp/tri4b/decode_tgsmall_train_clean_100/
. ./cmd.sh ## You'll want to change cmd.sh to something that will work on your system.
. ./path.sh ## Source the tools/utils (import the queue.pl)
gmmdir=exp/tri4b
for chunk in train_clean_100 dev_clean test_clean; do
dir=fmllr/$chunk
steps/nnet/make_fmllr_feats.sh --nj 10 --cmd "$train_cmd"
--transform-dir $gmmdir/decode_tgsmall_$chunk
$dir data/$chunk $gmmdir $dir/log $dir/data || exit 1
compute-cmvn-stats --spk2utt=ark:data/$chunk/spk2utt scp:fmllr/$chunk/feats.scp ark:$dir/data/cmvn_speaker.ark
done
# aligments on dev_clean and test_clean
steps/align_fmllr.sh --nj 30 data/train_clean_100 data/lang exp/tri4b exp/tri4b_ali_clean_100
steps/align_fmllr.sh --nj 10 data/dev_clean data/lang exp/tri4b exp/tri4b_ali_dev_clean_100
steps/align_fmllr.sh --nj 10 data/test_clean data/lang exp/tri4b exp/tri4b_ali_test_clean_100
python run_exp.py cfg/Librispeech_baselines/libri_MLP_fmllr.cfg
หากคุณต้องการใช้โมเดลที่เกิดขึ้นอีกคุณสามารถใช้ libri_rnn_fmllr.cfg , libri_lstm_fmllr.cfg , libri_gru_fmllr.cfg หรือ libri_ligru_fmllr.cfg การฝึกอบรมแบบจำลองที่เกิดขึ้นอีกอาจใช้เวลาหลายวัน (ขึ้นอยู่กับ GPU ที่รับเลี้ยง) ประสิทธิภาพที่ได้จากกราฟ TGSMALL มีการรายงานในตารางต่อไปนี้:
| แบบอย่าง | % |
|---|---|
| MLP | 9.6 |
| LSTM | 8.6 |
| กรุ | 8.6 |
| li-gru | 8.6 |
ผลลัพธ์เหล่านี้ได้รับโดยไม่ต้องเพิ่มการช่วยชีวิตของตาข่าย (เช่นโดยใช้กราฟ TGSMALL เท่านั้น) คุณสามารถปรับปรุงประสิทธิภาพได้โดยการเพิ่มการช่วยเหลือ Lattice ด้วยวิธีนี้ (เรียกใช้จากโฟลเดอร์ kaldi_decoding_script ของ pytorch-kaldi):
data_dir=/data/milatmp1/ravanelm/librispeech/s5/data/
dec_dir=/u/ravanelm/pytorch-Kaldi-new/exp/libri_fmllr/decode_test_clean_out_dnn1/
out_dir=/u/ravanelm/pytorch-kaldi-new/exp/libri_fmllr/
steps/lmrescore_const_arpa.sh $data_dir/lang_test_{tgsmall,fglarge}
$data_dir/test_clean $dec_dir $out_dir/decode_test_clean_fglarge || exit 1;
ผลลัพธ์สุดท้ายที่ได้รับโดยใช้การช่วยเหลือ ( fglarge ) มีการรายงานในตารางต่อไปนี้:
| แบบอย่าง | % |
|---|---|
| MLP | 6.5 |
| LSTM | 6.4 |
| กรุ | 6.3 |
| li-gru | 6.2 |
คุณสามารถดูผลลัพธ์ที่ได้ที่นี่
สคริปต์หลักในการเรียกใช้การทดลอง ASR คือ run_exp.py สคริปต์ Python นี้ดำเนินการฝึกอบรมการตรวจสอบความถูกต้องไปข้างหน้าและขั้นตอนการถอดรหัส การฝึกอบรมจะดำเนินการผ่านช่วงเวลาหลายครั้งซึ่งจะดำเนินการประมวลผลวัสดุการฝึกอบรมทั้งหมดด้วยเครือข่ายประสาทที่พิจารณา หลังจากแต่ละช่วงการฝึกอบรมขั้นตอนการตรวจสอบจะดำเนินการเพื่อตรวจสอบประสิทธิภาพของระบบบนข้อมูล ที่จัดขึ้น ในตอนท้ายของการฝึกอบรมเฟสไปข้างหน้าจะดำเนินการโดยการคำนวณความน่าจะเป็นหลังของชุดข้อมูลทดสอบที่ระบุ ความน่าจะเป็นหลังจะถูกทำให้เป็นมาตรฐานโดยนักบวช (ใช้ไฟล์นับ) และเก็บไว้ในไฟล์ ARK ขั้นตอนการถอดรหัสจะดำเนินการเพื่อดึงลำดับสุดท้ายของคำพูดที่พูดโดยผู้พูดในประโยคทดสอบ
สคริปต์ run_exp.py ใช้ในการป้อนไฟล์ config ทั่วโลก (เช่น cfg/timit_mlp_mfcc.cfg ) ที่ระบุตัวเลือกที่จำเป็นทั้งหมดเพื่อเรียกใช้การทดลองเต็มรูปแบบ รหัส run_exp.py เรียกใช้ฟังก์ชั่นอื่น run_nn (ดู Core.py Library) ที่ดำเนินการฝึกอบรมการตรวจสอบและการดำเนินการส่งต่อของข้อมูลแต่ละอัน ฟังก์ชั่น run_nn ใช้ในอินพุตไฟล์กำหนดค่าเฉพาะชิ้น (เช่น exp/timit_mlp_mfcc/exp_files/train_timit_tr+timit_dev_ep000_ck00.cfg*) ที่ระบุพารามิเตอร์ที่ต้องการทั้งหมด ฟังก์ชั่น run_nn ส่งออกข้อมูลบางอย่างเติม (เช่น exp/timit_mlp_mfcc/exp_files/train_timit_tr+timit_dev_ep000_ck00.info ) ที่สรุปการสูญเสียและข้อผิดพลาดของก้อนที่ผ่านการประมวลผล
ผลลัพธ์จะถูกสรุปลงในไฟล์ res.res ในขณะที่ข้อผิดพลาดและคำเตือนจะถูกเปลี่ยนเส้นทางไปยังไฟล์ log.log
ไฟล์ config มีสองประเภท (ไฟล์ CFG ที่เฉพาะเจาะจงและ global และเฉพาะ) พวกเขาทั้งในรูปแบบ INI และอ่านประมวลผลและแก้ไขด้วยไลบรารี configparser ของ Python ไฟล์ทั่วโลกมีหลายส่วนที่ระบุขั้นตอนหลักทั้งหมดของการทดลองรู้จำเสียงพูด (การฝึกอบรมการตรวจสอบการส่งต่อและการถอดรหัส) โครงสร้างของไฟล์ config อธิบายไว้ในไฟล์ต้นแบบ (ดูตัวอย่าง Proto/Global.proto ) ที่ไม่เพียง แต่แสดงรายการส่วนและฟิลด์ที่ต้องการทั้งหมด แต่ยังระบุประเภทของแต่ละฟิลด์ที่เป็นไปได้ ตัวอย่างเช่น n_ep = int (1, inf) หมายความว่าฟิลด์ n_ep (เช่นจำนวนการฝึกอบรมยุค) จะต้องเป็นจำนวนเต็มตั้งแต่ 1 ถึง inf ในทำนองเดียวกัน LR = Float (0, Inf) หมายความว่าสนาม LR (เช่นอัตราการเรียนรู้) จะต้องลอยอยู่ตั้งแต่ 0 ถึง INF ความพยายามใด ๆ ในการเขียนไฟล์กำหนดค่าที่ไม่สอดคล้องกับข้อกำหนดเหล่านี้จะทำให้เกิดข้อผิดพลาด
ตอนนี้ลองเปิดไฟล์กำหนดค่า (เช่น CFG/TIMIT_BASELINES/TIMIT_MLP_MFCC_BASIC.CFG ) และอธิบายส่วนหลัก:
[cfg_proto]
cfg_proto = proto/global.proto
cfg_proto_chunk = proto/global_chunk.proto
เวอร์ชันปัจจุบันของไฟล์ config ระบุเส้นทางของไฟล์ต้นแบบ Global และ Chunk เฉพาะในส่วน [CFG_PROTO]
[exp]
cmd =
run_nn_script = run_nn
out_folder = exp/TIMIT_MLP_basic5
seed = 1234
use_cuda = True
multi_gpu = False
save_gpumem = False
n_epochs_tr = 24
ส่วน [exp] มีฟิลด์ที่สำคัญบางอย่างเช่นโฟลเดอร์เอาท์พุท ( out_folder ) และเส้นทางของสคริปต์การประมวลผลเฉพาะก้อน run_nn (โดยค่าเริ่มต้นฟังก์ชั่นนี้ควรนำไปใช้ใน Core.py Library) ฟิลด์ N_EPOCHS_TR ระบุจำนวนยุคการฝึกอบรมที่เลือก ตัวเลือกอื่น ๆ เกี่ยวกับการใช้ _cuda, multi_gpu และ save_gpumem สามารถเปิดใช้งานได้โดยผู้ใช้ ฟิลด์ CMD สามารถใช้เพื่อผนวกคำสั่งเพื่อเรียกใช้สคริปต์บนคลัสเตอร์ HPC
[dataset1]
data_name = TIMIT_tr
fea = fea_name=mfcc
fea_lst=quick_test/data/train/feats_mfcc.scp
fea_opts=apply-cmvn --utt2spk=ark:quick_test/data/train/utt2spk ark:quick_test/mfcc/train_cmvn_speaker.ark ark:- ark:- | add-deltas --delta-order=2 ark:- ark:- |
cw_left=5
cw_right=5
lab = lab_name=lab_cd
lab_folder=quick_test/dnn4_pretrain-dbn_dnn_ali
lab_opts=ali-to-pdf
lab_count_file=auto
lab_data_folder=quick_test/data/train/
lab_graph=quick_test/graph
n_chunks = 5
[dataset2]
data_name = TIMIT_dev
fea = fea_name=mfcc
fea_lst=quick_test/data/dev/feats_mfcc.scp
fea_opts=apply-cmvn --utt2spk=ark:quick_test/data/dev/utt2spk ark:quick_test/mfcc/dev_cmvn_speaker.ark ark:- ark:- | add-deltas --delta-order=2 ark:- ark:- |
cw_left=5
cw_right=5
lab = lab_name=lab_cd
lab_folder=quick_test/dnn4_pretrain-dbn_dnn_ali_dev
lab_opts=ali-to-pdf
lab_count_file=auto
lab_data_folder=quick_test/data/dev/
lab_graph=quick_test/graph
n_chunks = 1
[dataset3]
data_name = TIMIT_test
fea = fea_name=mfcc
fea_lst=quick_test/data/test/feats_mfcc.scp
fea_opts=apply-cmvn --utt2spk=ark:quick_test/data/test/utt2spk ark:quick_test/mfcc/test_cmvn_speaker.ark ark:- ark:- | add-deltas --delta-order=2 ark:- ark:- |
cw_left=5
cw_right=5
lab = lab_name=lab_cd
lab_folder=quick_test/dnn4_pretrain-dbn_dnn_ali_test
lab_opts=ali-to-pdf
lab_count_file=auto
lab_data_folder=quick_test/data/test/
lab_graph=quick_test/graph
n_chunks = 1
ไฟล์ config มีจำนวนของส่วน ( [DataSet1] , [DataSet2] , [DataSet3] , ... ) ที่อธิบายถึง corpora ทั้งหมดที่ใช้สำหรับการทดลอง ASR ฟิลด์ในส่วน [ชุดข้อมูล*] อธิบายคุณสมบัติและฉลากทั้งหมดที่พิจารณาในการทดลอง ตัวอย่างเช่นคุณสมบัติมีการระบุไว้ในฟิลด์ fea: โดยที่ fea_name มีชื่อที่ให้ไว้ในคุณสมบัติ fea_lst เป็นรายการของคุณสมบัติ (ในรูปแบบ scp kaldi), fea_opts ช่วยให้ ผู้ ใช้ สามารถระบุวิธีการประมวลผลคุณสมบัติ (เช่นการทำตามจำนวน ผนวก) โปรดทราบว่าชุดเครื่องมือ Pytorch-Kaldi รุ่นปัจจุบันรองรับคำจำกัดความของสตรีมคุณสมบัติหลายอย่าง อันที่จริงดังที่แสดงใน CFG/TIMIT_BASELINES/TIMIT_MFCC_FBANK_FMLLR_LIGRU_BEST.CFG คุณลักษณะหลายสตรีม (เช่น MFCC, FBANK, FMLLR)
ในทำนองเดียวกันส่วนห้อง ปฏิบัติการ มีฟิลด์ย่อยบางส่วน ตัวอย่างเช่น lab_name หมายถึงชื่อที่ให้ไว้ในฉลากในขณะที่ lab_folder มีโฟลเดอร์ที่จัดเรียงการจัดตำแหน่งที่สร้างโดยสูตร kaldi LAB_OPTS อนุญาตให้ผู้ใช้ระบุตัวเลือกบางอย่างในการจัดตำแหน่งที่พิจารณา ตัวอย่างเช่น lab_opts = "Ali-to-pdf" แยกฉลากสถานะโทรศัพท์ตามบริบทที่ขึ้นอยู่กับมาตรฐานในขณะที่ lab_opts = Ali-to-phone-per-frame = True สามารถใช้เพื่อแยกเป้าหมาย monophone lab_count_file ใช้เพื่อระบุไฟล์ที่มีจำนวนของสถานะโทรศัพท์ที่พิจารณา การนับเหล่านี้มีความสำคัญในระยะไปข้างหน้าซึ่งความน่าจะเป็นหลังที่คำนวณโดยเครือข่ายประสาทถูกหารด้วยนักบวช Pytorch-Kaldi ช่วยให้ผู้ใช้สามารถระบุไฟล์จำนวนภายนอกหรือเรียกคืนได้โดยอัตโนมัติ (โดยใช้ lab_count_file = auto ) ผู้ใช้ยังสามารถระบุ lab_count_file = ไม่มี หากไฟล์นับไม่ต้องการอย่างเคร่งครัดเช่นเมื่อฉลากสอดคล้องกับเอาต์พุตที่ไม่ได้ใช้เพื่อสร้างความน่าจะเป็นหลัง ที่ ใช้ในเฟสไปข้างหน้า lab_data_folder แทนสอดคล้องกับโฟลเดอร์ข้อมูลที่สร้างขึ้นระหว่างการเตรียมข้อมูล Kaldi มันมีหลายไฟล์รวมถึงไฟล์ข้อความในที่สุดก็ใช้สำหรับการคำนวณของสุดท้าย WER lab_graph ฟิลด์ย่อยสุดท้ายเป็นเส้นทางของกราฟ kaldi ที่ใช้ในการสร้างฉลาก
ชุดข้อมูลเต็มรูปแบบมักจะมีขนาดใหญ่และไม่สามารถพอดีกับหน่วยความจำ GPU/RAM มันควรจะถูกแบ่งออกเป็นหลาย ๆ ชิ้น Pytorch-Kaldi จะแยกชุดข้อมูลออกเป็นจำนวนชิ้นที่ระบุไว้ใน N_CHUNKS โดยอัตโนมัติ จำนวนชิ้นอาจขึ้นอยู่กับชุดข้อมูลเฉพาะ โดยทั่วไปเราแนะนำให้ประมวลผลคำพูดประมาณ 1 หรือ 2 ชั่วโมง (ขึ้นอยู่กับหน่วยความจำที่มีอยู่)
[data_use]
train_with = TIMIT_tr
valid_with = TIMIT_dev
forward_with = TIMIT_test
ส่วนนี้จะบอกว่าข้อมูลที่ระบุไว้ในส่วน [ชุดข้อมูล*] ใช้ในสคริปต์ run_exp.py อย่างไร บรรทัดแรกหมายความว่าเราทำการฝึกอบรมด้วยข้อมูลที่เรียกว่า timit_tr โปรดทราบว่าชื่อชุดข้อมูลนี้จะต้องปรากฏในหนึ่งในส่วนชุดข้อมูลมิฉะนั้นตัวแยกวิเคราะห์ config จะเพิ่มข้อผิดพลาด ในทำนองเดียวกันบรรทัดที่สองและสามระบุข้อมูลที่ใช้สำหรับการตรวจสอบความถูกต้องและเฟสไปข้างหน้าตามลำดับ
[batches]
batch_size_train = 128
max_seq_length_train = 1000
increase_seq_length_train = False
start_seq_len_train = 100
multply_factor_seq_len_train = 2
batch_size_valid = 128
max_seq_length_valid = 1000
batch_size_train ใช้เพื่อกำหนดจำนวนตัวอย่างการฝึกอบรมในมินิแบทช์ ฟิลด์ max_seq_length_train ตัดทอนประโยคที่ยาวกว่าค่าที่ระบุ เมื่อการฝึกอบรมแบบจำลองที่เกิดขึ้นซ้ำ ๆ ในประโยคที่ยาวมากปัญหาที่เกิดขึ้นนอกหน่วยความจำอาจเกิดขึ้น ด้วยตัวเลือกนี้เราอนุญาตให้ผู้ใช้ลดปัญหาหน่วยความจำดังกล่าวโดยการตัดทอนประโยคยาว ยิ่งไปกว่านั้นมันเป็นไปได้ที่จะเพิ่มความยาวประโยคสูงสุดในระหว่างการฝึกอบรมโดยการตั้งค่า REPUST_SEQ_LENGTH_TRAIN = TRUE หากเปิดใช้งานการฝึกอบรมเริ่มต้นด้วยความยาวประโยคสูงสุดที่ระบุใน start_seq_len_train (เช่น start_seq_len_train = 100 ) หลังจากแต่ละยุคสมัยความยาวประโยคสูงสุดจะถูกคูณด้วย multply_factor_seq_len_train (เช่น multply_factor_seq_len_train = 2 ) เราได้สังเกตว่ากลยุทธ์ง่าย ๆ นี้จะช่วยปรับปรุงประสิทธิภาพของระบบเนื่องจากมันกระตุ้นให้แบบจำลองมุ่งเน้นไปที่การพึ่งพาระยะสั้นก่อนและเรียนรู้กลยุทธ์ระยะยาวในระยะต่อมา
ในทำนองเดียวกัน batch_size_valid และ max_seq_length_valid ระบุจำนวนตัวอย่างในมินิแบทช์และความยาวสูงสุดสำหรับชุดข้อมูล dev
[architecture1]
arch_name = MLP_layers1
arch_proto = proto/MLP.proto
arch_library = neural_networks
arch_class = MLP
arch_pretrain_file = none
arch_freeze = False
arch_seq_model = False
dnn_lay = 1024,1024,1024,1024,N_out_lab_cd
dnn_drop = 0.15,0.15,0.15,0.15,0.0
dnn_use_laynorm_inp = False
dnn_use_batchnorm_inp = False
dnn_use_batchnorm = True,True,True,True,False
dnn_use_laynorm = False,False,False,False,False
dnn_act = relu,relu,relu,relu,softmax
arch_lr = 0.08
arch_halving_factor = 0.5
arch_improvement_threshold = 0.001
arch_opt = sgd
opt_momentum = 0.0
opt_weight_decay = 0.0
opt_dampening = 0.0
opt_nesterov = False
ส่วน [สถาปัตยกรรม*] ใช้เพื่อระบุสถาปัตยกรรมของเครือข่ายประสาทที่เกี่ยวข้องในการทดลอง ASR ฟิลด์ arch_name ระบุชื่อของสถาปัตยกรรม เนื่องจากเครือข่ายประสาทที่แตกต่างกันสามารถขึ้นอยู่กับชุดพารามิเตอร์ที่แตกต่างกันผู้ใช้จึงต้องเพิ่มเส้นทางของไฟล์โปรโตที่มีรายการของพารามิเตอร์ไฮเปอร์พารามิเตอร์ลงในฟิลด์ โปรโต ตัวอย่างเช่นไฟล์ต้นแบบสำหรับโมเดล MLP มาตรฐานมีฟิลด์ต่อไปนี้:
[proto]
library=path
class=MLP
dnn_lay=str_list
dnn_drop=float_list(0.0,1.0)
dnn_use_laynorm_inp=bool
dnn_use_batchnorm_inp=bool
dnn_use_batchnorm=bool_list
dnn_use_laynorm=bool_list
dnn_act=str_list
ในทำนองเดียวกันกับไฟล์ต้นแบบอื่น ๆ แต่ละบรรทัดจะกำหนดพารามิเตอร์ hyperparameter ด้วยประเภทค่าที่เกี่ยวข้อง HyperParameters ทั้งหมดที่กำหนดไว้ในไฟล์ Proto จะต้องปรากฏในไฟล์การกำหนดค่าส่วนกลางภายใต้ส่วน [สถาปัตยกรรม*] ที่สอดคล้องกัน ฟิลด์ arch_library ระบุตำแหน่งที่โมเดลถูกเข้ารหัส (เช่น neural_nets.py ) ในขณะที่ Arch_class ระบุชื่อของคลาสที่มีการใช้สถาปัตยกรรม (เช่นถ้าเราตั้งค่า คลาส = MLP เราจะทำ จาก Neural_nets.py นำเข้า MLP )
field arch_pretrain_file สามารถใช้เพื่อฝึกอบรมเครือข่ายประสาทด้วยสถาปัตยกรรมที่ผ่านการฝึกอบรมมาก่อนหน้านี้ในขณะที่ arch_freeze สามารถตั้งค่าเป็น เท็จได้ หากคุณต้องการฝึกอบรมพารามิเตอร์ของสถาปัตยกรรมในระหว่างการฝึกอบรมและควรตั้งค่าให้เป็น จริง ส่วน Arch_seq_model ระบุว่าสถาปัตยกรรมเป็นลำดับ (เช่น rnns) หรือไม่ต่อเนื่อง (เช่นฟีดไปข้างหน้า MLP หรือ CNN) วิธีที่ Pytorch-Kaldi ประมวลผลแบทช์อินพุตนั้นแตกต่างกันในสองกรณี สำหรับเครือข่ายประสาทที่เกิดขึ้นซ้ำ ( Arch_seq_model = TRUE ) ลำดับของคุณสมบัติไม่ได้สุ่ม (เพื่อรักษาองค์ประกอบของลำดับ) ในขณะที่สำหรับแบบจำลอง Feedforward ( Arch_seq_model = False ) เราสุ่มคุณสมบัติ (ซึ่งมักจะช่วยปรับปรุงประสิทธิภาพ) ในกรณีของสถาปัตยกรรมที่หลากหลายการประมวลผลตามลำดับจะถูกใช้หากอย่างน้อยหนึ่งในสถาปัตยกรรมที่ใช้งานถูกทำเครื่องหมายเป็นลำดับ ( Arch_seq_model = TRUE )
โปรดทราบว่า hyperparameters ที่ขึ้นต้นด้วย "arch_" และ "opt_" เป็นสิ่งจำเป็นและจะต้องมีอยู่ในสถาปัตยกรรมทั้งหมดที่ระบุในไฟล์ config hyperparameters อื่น ๆ (เช่น DNN_*,) เป็นเฉพาะของสถาปัตยกรรมที่พิจารณา (ขึ้นอยู่กับวิธีการใช้ MLP คลาสจริงโดยผู้ใช้) และสามารถกำหนดจำนวนและประเภทของเลเยอร์ที่ซ่อนอยู่แบทช์และเลเยอร์และพารามิเตอร์อื่น ๆ พารามิเตอร์ที่สำคัญอื่น ๆ เกี่ยวข้องกับการเพิ่มประสิทธิภาพของสถาปัตยกรรมที่พิจารณา ตัวอย่างเช่น arch_lr เป็นอัตราการเรียนรู้ในขณะที่ arch_halving_factor ใช้เพื่อใช้การหลอมอัตราการเรียนรู้ โดยเฉพาะอย่างยิ่งเมื่อการปรับปรุงประสิทธิภาพสัมพัทธ์ของ dev-set ระหว่างสอง epochs ติดต่อกันมีขนาดเล็กกว่าที่ระบุใน arch_improvement_threshold (เช่น arch_improvement_threshold) เราทวีคูณอัตราการเรียนรู้โดย arch_halving_factor (เช่น arch_halving_factor = 0.5 ) FIELD ARCH_OPT ระบุประเภทของอัลกอริทึมการเพิ่มประสิทธิภาพ ขณะนี้เราสนับสนุน SGD, Adam และ RMSPROP พารามิเตอร์อื่น ๆ นั้นมีความเฉพาะเจาะจงกับอัลกอริทึมการเพิ่มประสิทธิภาพที่พิจารณาแล้ว (ดูเอกสารประกอบ Pytorch สำหรับความหมายที่แน่นอนของพารามิเตอร์ที่เฉพาะเจาะจงเฉพาะทั้งหมด) โปรดทราบว่าสถาปัตยกรรมที่แตกต่างกันที่กำหนดไว้ใน [archictecture*] สามารถมีพารามิเตอร์การเพิ่มประสิทธิภาพที่แตกต่างกันและพวกเขายังสามารถใช้อัลกอริทึมการเพิ่มประสิทธิภาพที่แตกต่างกัน
[model]
model_proto = proto/model.proto
model = out_dnn1=compute(MLP_layers1,mfcc)
loss_final=cost_nll(out_dnn1,lab_cd)
err_final=cost_err(out_dnn1,lab_cd)
วิธีการรวมคุณสมบัติและสถาปัตยกรรมที่หลากหลายทั้งหมดถูกระบุไว้ในส่วนนี้ด้วยภาษาเมตาที่ง่ายและใช้งานง่าย โมเดลฟิลด์: อธิบายถึงวิธีการเชื่อมต่อคุณสมบัติและสถาปัตยกรรมเพื่อสร้างเป็นเอาต์พุตชุดของความน่าจะเป็นหลัง บรรทัด out_dnn1 = การคำนวณ (mlp_layers, mfcc) หมายถึง " ฟีดสถาปัตยกรรมที่เรียกว่า mlp_layers1 พร้อมคุณสมบัติที่เรียกว่า MFCC และเก็บเอาต์พุตลงในตัวแปร out_dnn1 " จากเอาต์พุตเครือข่ายประสาท out_dnn1 ข้อผิดพลาดและฟังก์ชั่นการสูญเสียถูกคำนวณโดยใช้ป้ายกำกับที่เรียกว่า lab_cd ซึ่งจะต้องกำหนดไว้ก่อนหน้านี้ในส่วน [ชุดข้อมูล*] ฟิลด์ ERR_FINAL และ LOSCE_FINAL เป็นฟิลด์ย่อยที่บังคับซึ่งกำหนดผลลัพธ์สุดท้ายของโมเดล
ตัวอย่างที่ซับซ้อนมากขึ้น (กล่าวถึงที่นี่เพียงเพื่อเน้นศักยภาพของชุดเครื่องมือ) ใน CFG/timit_baselines/timit_mfcc_fbank_fmllr_ligru_best.cfg :
[model]
model_proto=proto/model.proto
model:conc1=concatenate(mfcc,fbank)
conc2=concatenate(conc1,fmllr)
out_dnn1=compute(MLP_layers_first,conc2)
out_dnn2=compute(liGRU_layers,out_dnn1)
out_dnn3=compute(MLP_layers_second,out_dnn2)
out_dnn4=compute(MLP_layers_last,out_dnn3)
out_dnn5=compute(MLP_layers_last2,out_dnn3)
loss_mono=cost_nll(out_dnn5,lab_mono)
loss_mono_w=mult_constant(loss_mono,1.0)
loss_cd=cost_nll(out_dnn4,lab_cd)
loss_final=sum(loss_cd,loss_mono_w)
err_final=cost_err(out_dnn4,lab_cd)
ในกรณีนี้เราจะรวมคุณสมบัติ MFCC, FBANK และ FMLLR เป็นครั้งแรกและจากนั้นเราก็ให้อาหาร MLP ผลลัพธ์ของ MLP ถูกป้อนเข้าสู่เครือข่ายประสาทที่เกิดขึ้นอีก (โดยเฉพาะแบบจำลอง Li-GRU) จากนั้นเรามีเลเยอร์ MLP อื่น ( MLP_LAYERS_SECOND ) ตามด้วยตัวแยกประเภท SoftMax สองตัว (เช่น MLP_LAYERS_LAST , MLP_LAYERS_LAST2 ) คนแรกประมาณสถานะที่ขึ้นอยู่กับบริบทมาตรฐานในขณะที่การประเมินเป้าหมายโมโนโฟนครั้งที่สอง ฟังก์ชั่นต้นทุนสุดท้ายคือผลรวมถ่วงน้ำหนักระหว่างการคาดการณ์ทั้งสองนี้ ด้วยวิธีนี้เราใช้การทำให้เป็นมาตรฐาน monophone ซึ่งกลายเป็นประโยชน์ในการปรับปรุงประสิทธิภาพ ASR
โมเดลเต็มรูปแบบถือได้ว่าเป็นกราฟการคำนวณขนาดใหญ่เดียวซึ่งสถาปัตยกรรมพื้นฐานทั้งหมดที่ใช้ในส่วน [โมเดล] ได้รับการฝึกฝนร่วมกัน สำหรับมินิแบทช์แต่ละตัวคุณลักษณะอินพุตจะถูกเผยแพร่ผ่านรุ่นเต็มและคำนวณ cost_final โดยใช้ฉลากที่ระบุ การไล่ระดับสีของฟังก์ชั่นต้นทุนที่เกี่ยวข้องกับพารามิเตอร์ที่เรียนรู้ทั้งหมดของสถาปัตยกรรมจะถูกคำนวณ พารามิเตอร์ทั้งหมดของสถาปัตยกรรมที่ใช้งานจะได้รับการปรับปรุงพร้อมกับอัลกอริทึมที่ระบุในส่วน [สถาปัตยกรรม*]
[forward]
forward_out = out_dnn1
normalize_posteriors = True
normalize_with_counts_from = lab_cd
save_out_file = True
require_decoding = True
การส่งต่อส่วนแรกจะกำหนดซึ่งเป็นเอาต์พุตไปข้างหน้า (จะต้องกำหนดไว้ในส่วนโมเดล) หาก normalize_posteriors = true หลังเหล่านี้จะถูกทำให้เป็นมาตรฐานโดยนักบวชของพวกเขา (ใช้ไฟล์นับ) หาก save_out_file = true ไฟล์หลัง (โดยปกติจะเป็นไฟล์ ARK ที่ใหญ่มาก) จะถูกเก็บไว้ในขณะที่ถ้า save_out_file = false ไฟล์นี้จะถูกลบเมื่อไม่จำเป็นอีกต่อไป require_decoding เป็นบูลีนที่ระบุว่าเราจำเป็นต้องถอดรหัสเอาต์พุตที่ระบุ ฟิลด์ normalize_with_counts_from ชุดซึ่งนับโดยใช้เพื่อทำให้ความน่าจะเป็นหลังปกติ
[decoding]
decoding_script_folder = kaldi_decoding_scripts/
decoding_script = decode_dnn.sh
decoding_proto = proto/decoding.proto
min_active = 200
max_active = 7000
max_mem = 50000000
beam = 13.0
latbeam = 8.0
acwt = 0.2
max_arcs = -1
skip_scoring = false
scoring_script = local/score.sh
scoring_opts = "--min-lmwt 1 --max-lmwt 10"
norm_vars = False
ส่วนการถอดรหัสรายงานพารามิเตอร์เกี่ยวกับการถอดรหัสเช่นขั้นตอนที่อนุญาตให้หนึ่งผ่านจากลำดับของความน่าจะเป็นขึ้นอยู่กับบริบทที่จัดทำโดย DNN เป็นลำดับของคำ ฟิลด์ DECODING_SCRIPT_Folder ระบุโฟลเดอร์ที่เก็บสคริปต์การถอดรหัสไว้ The decoding script field is the script used for decoding (eg, decode_dnn.sh ) that should be in the decoding_script_folder specified before. The field decoding_proto reports all the parameters needed for the considered decoding script.
To make the code more flexible, the config parameters can also be specified within the command line. For example, you can run:
python run_exp.py quick_test/example_newcode.cfg --optimization,lr=0.01 --batches,batch_size=4
The script will replace the learning rate in the specified cfg file with the specified lr value. The modified config file is then stored into out_folder/config.cfg .
The script run_exp.py automatically creates chunk-specific config files, that are used by the run_nn function to perform a single chunk training. The structure of chunk-specific cfg files is very similar to that of the global one. The main difference is a field to_do={train, valid, forward} that specifies the type of processing to on the features chunk specified in the field fea .
Why proto files? Different neural networks, optimization algorithms, and HMM decoders might depend on a different set of hyperparameters. To address this issue, our current solution is based on the definition of some prototype files (for global, chunk, architecture config files). In general, this approach allows a more transparent check of the fields specified into the global config file. Moreover, it allows users to easily add new parameters without changing any line of the python code. For instance, to add a user-defined model, a new proto file (eg, user-model.prot o) that specifies the hyperparameter must be written. Then, the user should only write a class (eg, user-model in neural_networks.py ) that implements the architecture).
The toolkit is designed to allow users to easily plug-in their own acoustic models. To add a customized neural model do the following steps:
[proto]
dnn_lay=str_list
dnn_drop=float_list(0.0,1.0)
dnn_use_laynorm_inp=bool
dnn_use_batchnorm_inp=bool
dnn_use_batchnorm=bool_list
dnn_use_laynorm=bool_list
dnn_act=str_list
The parameter dnn_lay must be a list of string, dnn_drop (ie, the dropout factors for each layer) is a list of float ranging from 0.0 and 1.0, dnn_use_laynorm_inp and dnn_use_batchnorm_inp are booleans that enable or disable batch or layer normalization of the input. dnn_use_batchnorm and dnn_use_laynorm are a list of boolean that decide layer by layer if batch/layer normalization has to be used. The parameter dnn_act is again a list of string that sets the activation function of each layer. Since every model is based on its own set of hyperparameters, different models have a different prototype file. For instance, you can take a look into GRU.proto and see that the hyperparameter list is different from that of a standard MLP. Similarly to the previous examples, you should add here your list of hyperparameters and save the file.
Write a PyTorch class implementing your model. Open the library neural_networks.py and look at some of the models already implemented. For simplicity, you can start taking a look into the class MLP. The classes have two mandatory methods: init and forward . The first one is used to initialize the architecture, the second specifies the list of computations to do. The method init takes in input two variables that are automatically computed within the run_nn function. inp_dim is simply the dimensionality of the neural network input, while options is a dictionary containing all the parameters specified into the section architecture of the configuration file.
For instance, you can access to the DNN activations of the various layers in this way: options['dnn_lay'].split(',') . As you might see from the MLP class, the initialization method defines and initializes all the parameters of the neural network. The forward method takes in input a tensor x (ie, the input data) and outputs another vector containing x. If your model is a sequence model (ie, if there is at least one architecture with arch_seq_model=true in the cfg file), x is a tensor with (time_steps, batches, N_in), otherwise is a (batches, N_in) matrix. The class forward defines the list of computations to transform the input tensor into a corresponding output tensor. The output must have the sequential format (time_steps, batches, N_out) for recurrent models and the non-sequential format (batches, N_out) for feed-forward models. Similarly to the already-implemented models the user should write a new class (eg, myDNN) that implements the customized model:
class myDNN(nn.Module):
def __init__(self, options,inp_dim):
super(myDNN, self).__init__()
// initialize the parameters
def forward(self, x):
// do some computations out=f(x)
return out
[architecture1]
arch_name= mynetwork (this is a name you would like to use to refer to this architecture within the following model section)
arch_proto=proto/myDNN.proto (here is the name of the proto file defined before)
arch_library=neural_networks (this is the name of the library where myDNN is implemented)
arch_class=myDNN (This must be the name of the class you have implemented)
arch_pretrain_file=none (With this you can specify if you want to pre-train your model)
arch_freeze=False (set False if you want to update the parameters of your model)
arch_seq_model=False (set False for feed-forward models, True for recurrent models)
Then, you have to specify proper values for all the hyperparameters specified in proto/myDNN.proto . For the MLP.proto , we have:
dnn_lay=1024,1024,1024,1024,1024,N_out_lab_cd
dnn_drop=0.15,0.15,0.15,0.15,0.15,0.0
dnn_use_laynorm_inp=False
dnn_use_batchnorm_inp=False
dnn_use_batchnorm=True,True,True,True,True,False
dnn_use_laynorm=False,False,False,False,False,False
dnn_act=relu,relu,relu,relu,relu,softmax
Then, add the following parameters related to the optimization of your own architecture. You can use here standard sdg, adam, or rmsprop (see cfg/TIMIT_baselines/TIMIT_LSTM_mfcc.cfg for an example with rmsprop):
arch_lr=0.08
arch_halving_factor=0.5
arch_improvement_threshold=0.001
arch_opt=sgd
opt_momentum=0.0
opt_weight_decay=0.0
opt_dampening=0.0
opt_nesterov=False
Save the configuration file into the cfg folder (eg, cfg/myDNN_exp.cfg ).
Run the experiment with:
python run_exp.py cfg/myDNN_exp.cfg
When implementing a new model, an important debug test consists of doing an overfitting experiment (to make sure that the model is able to overfit a tiny dataset). If the model is not able to overfit, it means that there is a major bug to solve.
A hyperparameter tuning is often needed in deep learning to search for proper neural architectures. To help tuning the hyperparameters within PyTorch-Kaldi, we have implemented a simple utility that implements a random search. In particular, the script tune_hyperparameters.py generates a set of random configuration files and can be run in this way:
python tune_hyperparameters.py cfg/TIMIT_MLP_mfcc.cfg exp/TIMIT_MLP_mfcc_tuning 10 arch_lr=randfloat(0.001,0.01) batch_size_train=randint(32,256) dnn_act=choose_str{relu,relu,relu,relu,softmax|tanh,tanh,tanh,tanh,softmax}
The first parameter is the reference cfg file that we would like to modify, while the second one is the folder where the random configuration files are saved. The third parameter is the number of the random config file that we would like to generate. There is then the list of all the hyperparameters that we want to change. For instance, arch_lr=randfloat(0.001,0.01) will replace the field arch_lr with a random float ranging from 0.001 to 0.01. batch_size_train=randint(32,256) will replace batch_size_train with a random integer between 32 and 256 and so on. Once the config files are created, they can be run sequentially or in parallel with:
python run_exp.py $cfg_file
PyTorch-Kaldi can be used with any speech dataset. To use your own dataset, the steps to take are similar to those discussed in the TIMIT/Librispeech tutorials. In general, what you have to do is the following:
python run_exp.py $cfg_file . The current version of PyTorch-Kaldi supports input features stored with the Kaldi ark format. If the user wants to perform experiments with customized features, the latter must be converted into the ark format. Take a look into the Kaldi-io-for-python git repository (https://github.com/vesis84/kaldi-io-for-python) for a detailed description about converting numpy arrays into ark files. Moreover, you can take a look into our utility called save_raw_fea.py. This script generates Kaldi ark files containing raw features, that are later used to train neural networks fed by the raw waveform directly (see the section about processing audio with SincNet).
The current version of Pytorch-Kaldi supports the standard production process of using a Pytorch-Kaldi pre-trained acoustic model to transcript one or multiples .wav files. It is important to understand that you must have a trained Pytorch-Kaldi model. While you don't need labels or alignments anymore, Pytorch-Kaldi still needs many files to transcript a new audio file:
Once you have all these files, you can start adding your dataset section to the global configuration file. The easiest way is to copy the cfg file used to train your acoustic model and just modify by adding a new [dataset] :
[dataset4]
data_name = myWavFile
fea = fea_name=fbank
fea_lst=myWavFilePath/data/feats.scp
fea_opts=apply-cmvn --utt2spk=ark:myWavFilePath/data//utt2spk ark:myWavFilePath/cmvn_test.ark ark:- ark:- | add-deltas --delta-order=0 ark:- ark:- |
cw_left=5
cw_right=5
lab = lab_name=none
lab_data_folder=myWavFilePath/data/
lab_graph=myWavFilePath/exp/tri3/graph
n_chunks=1
[data_use]
train_with = TIMIT_tr
valid_with = TIMIT_dev
forward_with = myWavFile
The key string for your audio file transcription is lab_name=none . The none tag asks Pytorch-Kaldi to enter a production mode that only does the forward propagation and decoding without any labels. You don't need TIMIT_tr and TIMIT_dev to be on your production server since Pytorch-Kaldi will skip this information to directly go to the forward phase of the dataset given in the forward_with field. As you can see, the global fea field requires the exact same parameters than standard training or testing dataset, while the lab field only requires two parameters. Please, note that lab_data_folder is nothing more than the same path as fea_lst . Finally, you still need to specify the number of chunks you want to create to process this file (1 hour = 1 chunk).
WARNINGS
In your standard .cfg, you might have used keywords such as N_out_lab_cd that can not be used anymore. Indeed, in a production scenario, you don't want to have the training data on your machine. Therefore, all the variables that were on your .cfg file must be replaced by their true values. To replace all the N_out_{mono,lab_cd} you can take a look at the output of:
hmm-info /path/to/the/final.mdl/used/to/generate/the/training/ali
Then, if you normalize posteriors as (check in your .cfg Section forward):
normalize_posteriors = True
normalize_with_counts_from = lab_cd
You must replace lab_cd by:
normalize_posteriors = True
normalize_with_counts_from = /path/to/ali_train_pdf.counts
This normalization step is crucial for HMM-DNN speech recognition. DNNs, in fact, provide posterior probabilities, while HMMs are generative models that work with likelihoods. To derive the required likelihoods, one can simply divide the posteriors by the prior probabilities. To create this ali_train_pdf.counts file you can follow:
alidir=/path/to/the/exp/tri_ali (change it with your path to the exp with the ali)
num_pdf=$(hmm-info $alidir/final.mdl | awk '/pdfs/{print $4}')
labels_tr_pdf="ark:ali-to-pdf $alidir/final.mdl "ark:gunzip -c $alidir/ali.*.gz |" ark:- |"
analyze-counts --verbose=1 --binary=false --counts-dim=$num_pdf "$labels_tr_pdf" ali_train_pdf.counts
et voilà ! In a production scenario, you might need to transcript a huge number of audio files, and you don't want to create as much as needed .cfg file. In this extent, and after creating this initial production .cfg file (you can leave the path blank), you can call the run_exp.py script with specific arguments referring to your different.wav features:
python run_exp.py cfg/TIMIT_baselines/TIMIT_MLP_fbank_prod.cfg --dataset4,fea,0,fea_lst="myWavFilePath/data/feats.scp" --dataset4,lab,0,lab_data_folder="myWavFilePath/data/" --dataset4,lab,0,lab_graph="myWavFilePath/exp/tri3/graph/"
This command will internally alter the configuration file with your specified paths, and run and your defined features! Note that passing long arguments to the run_exp.py script requires a specific notation. --dataset4 specifies the name of the created section, fea is the name of the higher level field, fea_lst or lab_graph are the name of the lowest level field you want to change. The 0 is here to indicate which lowest level field you want to alter, indeed some configuration files may contain multiple lab_graph per dataset! Therefore, 0 indicates the first occurrence, 1 the second ... Paths MUST be encapsulated by " " to be interpreted as full strings! Note that you need to alter the data_name and forward_with fields if you don't want different .wav files transcriptions to erase each other (decoding files are stored accordingly to the field data_name ). --dataset4,data_name=MyNewName --data_use,forward_with=MyNewName .
In order to give users more flexibility, the latest version of PyTorch-Kaldi supports scheduling of the batch size, max_seq_length_train, learning rate, and dropout factor. This means that it is now possible to change these values during training. To support this feature, we implemented the following formalisms within the config files:
batch_size_train = 128*12 | 64*10 | 32*2
In this case, our batch size will be 128 for the first 12 epochs, 64 for the following 10 epochs, and 32 for the last two epochs. By default "*" means "for N times", while "|" is used to indicate a change of the batch size. Note that if the user simply sets batch_size_train = 128 , the batch size is kept fixed during all the training epochs by default.
A similar formalism can be used to perform learning rate scheduling:
arch_lr = 0.08*10|0.04*5|0.02*3|0.01*2|0.005*2|0.0025*2
In this case, if the user simply sets arch_lr = 0.08 the learning rate is annealed with the new-bob procedure used in the previous version of the toolkit. In practice, we start from the specified learning rate and we multiply it by a halving factor every time that the improvement on the validation dataset is smaller than the threshold specified in the field arch_improvement_threshold .
Also the dropout factor can now be changed during training with the following formalism:
dnn_drop = 0.15*12|0.20*12,0.15,0.15*10|0.20*14,0.15,0.0
With the line before we can set a different dropout rate for different layers and for different epochs. For instance, the first hidden layer will have a dropout rate of 0.15 for the first 12 epochs, and 0.20 for the other 12. The dropout factor of the second layer, instead, will remain constant to 0.15 over all the training. The same formalism is used for all the layers. Note that "|" indicates a change in the dropout factor within the same layer, while "," indicates a different layer.
You can take a look here into a config file where batch sizes, learning rates, and dropout factors are changed here:
cfg/TIMIT_baselines/TIMIT_mfcc_basic_flex.cfg
or here:
cfg/TIMIT_baselines/TIMIT_liGRU_fmllr_lr_schedule.cfg
The project is still in its initial phase and we invite all potential contributors to participate. We hope to build a community of developers larger enough to progressively maintain, improve, and expand the functionalities of our current toolkit. For instance, it could be helpful to report any bug or any suggestion to improve the current version of the code. People can also contribute by adding additional neural models, that can eventually make richer the set of currently-implemented architectures.
ลองดูวิดีโอแนะนำของเราเกี่ยวกับ Sincnet
SincNet is a convolutional neural network recently proposed to process raw audio waveforms. In particular, SincNet encourages the first layer to discover more meaningful filters by exploiting parametrized sinc functions. In contrast to standard CNNs, which learn all the elements of each filter, only low and high cutoff frequencies of band-pass filters are directly learned from data. This inductive bias offers a very compact way to derive a customized filter-bank front-end, that only depends on some parameters with a clear physical meaning.
For a more detailed description of the SincNet model, please refer to the following papers:
M. Ravanelli, Y. Bengio, "Speaker Recognition from raw waveform with SincNet", in Proc. of SLT 2018 ArXiv
M. Ravanelli, Y.Bengio, "Interpretable Convolutional Filters with SincNet", in Proc. of NIPS@IRASL 2018 ArXiv
To use this model for speech recognition on TIMIT, to the following steps:
python ./run_exp.py cfg/TIMIT_baselines/TIMIT_SincNet_raw.cfg
In the following table, we compare the result of SincNet with other feed-forward neural network:
| แบบอย่าง | WER(%) |
|---|---|
| MLP -fbank | 18.7 |
| MLP -mfcc | 18.2 |
| CNN -raw | 18.1 |
| SincNet -raw | 17.2 |
In this section, we show how to use PyTorch-Kaldi to jointly train a cascade between a speech enhancement and a speech recognition neural networks. The speech enhancement has the goal of improving the quality of the speech signal by minimizing the MSE between clean and noisy features. The enhanced features then feed another neural network that predicts context-dependent phone states.
In the following, we report a toy-task example based on a reverberated version of TIMIT, that is only intended to show how users should set the config file to train such a combination of neural networks. Even though some implementation details (and the adopted datasets) are different, this tutorial is inspired by this paper:
To run the system do the following steps:
1- Make sure you have the standard clean version of TIMIT available.
2- Run the Kaldi s5 baseline of TIMIT. This step is necessary to compute the clean features (that will be the labels of the speech enhancement system) and the alignments (that will be the labels of the speech recognition system). We recommend running the full timit s5 recipe (including the DNN training).
3- The standard TIMIT recipe uses MFCCs features. In this tutorial, instead, we use FBANK features. To compute FBANK features run the following script in $KALDI_ROOT/egs/TIMIT/s5 :
feadir=fbank
for x in train dev test; do
steps/make_fbank.sh --cmd "$train_cmd" --nj $feats_nj data/$x exp/make_fbank/$x $feadir
steps/compute_cmvn_stats.sh data/$x exp/make_fbank/$x $feadir
done
Note that we use 40 FBANKS here, while Kaldi uses by default 23 FBANKs. To compute 40-dimensional features go into "$KALDI_ROOT/egs/TIMIT/conf/fbank.conf" and change the number of considered output filters.
4- Go to this external repository and follow the steps to generate a reverberated version of TIMIT starting from the clean one. Note that this is just a toy task that is only helpful to show how setting up a joint-training system.
5- Compute the FBANK features for the TIMIT_rev dataset. To do it, you can copy the scripts in $KALDI_ROOT/egs/TIMIT/ into $KALDI_ROOT/egs/TIMIT_rev/ . Please, copy also the data folder. Note that the audio files in the TIMIT_rev folders are saved with the standard WAV format, while TIMIT is released with the SPHERE format. To bypass this issue, open the files data/train/wav.scp , data/dev/wav.scp , data/test/wav.scp and delete the part about SPHERE reading (eg, /home/mirco/kaldi-trunk/tools/sph2pipe_v2.5/sph2pipe -f wav ). You also have to change the paths from the standard TIMIT to the reverberated one (eg replace /TIMIT/ with /TIMIT_rev/). Remind to remove the final pipeline symbol“ |”. Save the changes and run the computation of the fbank features in this way:
feadir=fbank
for x in train dev test; do
steps/make_fbank.sh --cmd "$train_cmd" --nj $feats_nj data/$x exp/make_fbank/$x $feadir
steps/compute_cmvn_stats.sh data/$x exp/make_fbank/$x $feadir
done
Remember to change the $KALDI_ROOT/egs/TIMIT_rev/conf/fbank.conf file in order to compute 40 features rather than the 23 FBANKS of the default configuration.
6- Once features are computed, open the following config file:
cfg/TIMIT_baselines/TIMIT_rev/TIMIT_joint_training_liGRU_fbank.cfg
Remember to change the paths according to where data are stored in your machine. As you can see, we consider two types of features. The fbank_rev features are computed from the TIMIT_rev dataset, while the fbank_clean features are derived from the standard TIMIT dataset and are used as targets for the speech enhancement neural network. As you can see in the [model] section of the config file, we have the cascade between networks doing speech enhancement and speech recognition. The speech recognition architecture jointly estimates both context-dependent and monophone targets (thus using the so-called monophone regularization). To run an experiment type the following command:
python run_exp.py cfg/TIMIT_baselines/TIMIT_rev/TIMIT_joint_training_liGRU_fbank.cfg
7- Results With this configuration file, you should obtain a Phone Error Rate (PER)=28.1% . Note that some oscillations around this performance are more than natural and are due to different initialization of the neural parameters.
You can take a closer look into our results here
In this tutorial, we use the DIRHA-English dataset to perform a distant speech recognition experiment. The DIRHA English Dataset is a multi-microphone speech corpus being developed under the EC project DIRHA. The corpus is composed of both real and simulated sequences recorded with 32 sample-synchronized microphones in a domestic environment. The database contains signals of different characteristics in terms of noise and reverberation making it suitable for various multi-microphone signal processing and distant speech recognition tasks. The part of the dataset currently released is composed of 6 native US speakers (3 Males, 3 Females) uttering 409 wall-street journal sentences. The training data have been created using a realistic data contamination approach, that is based on contaminating the clean speech wsj-5k sentences with high-quality multi-microphone impulse responses measured in the targeted environment. For more details on this dataset, please refer to the following papers:
M. Ravanelli, L. Cristoforetti, R. Gretter, M. Pellin, A. Sosi, M. Omologo, "The DIRHA-English corpus and related tasks for distant-speech recognition in domestic environments", in Proceedings of ASRU 2015. ArXiv
M. Ravanelli, P. Svaizer, M. Omologo, "Realistic Multi-Microphone Data Simulation for Distant Speech Recognition", in Proceedings of Interspeech 2016. ArXiv
In this tutorial, we use the aforementioned simulated data for training (using LA6 microphone), while test is performed using the real recordings (LA6). This task is very realistic, but also very challenging. The speech signals are characterized by a reverberation time of about 0.7 seconds. Non-stationary domestic noises (such as vacuum cleaner, steps, phone rings, etc.) are also present in the real recordings.
Let's start now with the practical tutorial.
1- If not available, download the DIRHA dataset from the LDC website. LDC releases the full dataset for a small fee.
2- Go this external reposotory. As reported in this repository, you have to generate the contaminated WSJ dataset with the provided MATLAB script. Then, you can run the proposed KALDI baseline to have features and labels ready for our pytorch-kaldi toolkit.
3- Open the following configuration file:
cfg/DIRHA_baselines/DIRHA_liGRU_fmllr.cfg
The latter configuration file implements a simple RNN model based on a Light Gated Recurrent Unit (Li-GRU). We used fMLLR as input features. Change the paths and run the following command:
python run_exp.py cfg/DIRHA_baselines/DIRHA_liGRU_fmllr.cfg
4- Results: The aforementioned system should provide Word Error Rate (WER%)=23.2% . You can find the results obtained by us here.
Using the other configuration files in the cfg/DIRHA_baselines folder you can perform experiments with different setups. With the provided configuration files you can obtain the following results:
| แบบอย่าง | WER(%) |
|---|---|
| MLP | 26.1 |
| กรุ | 25.3 |
| Li-GRU | 23.8 |
The current version of the repository is mainly designed for speech recognition experiments. We are actively working a new version, which is much more flexible and can manage input/output different from Kaldi features/labels. Even with the current version, however, it is possible to implement other systems, such as an autoencoder.
An autoencoder is a neural network whose inputs and outputs are the same. The middle layer normally contains a bottleneck that forces our representations to compress the information of the input. In this tutorial, we provide a toy example based on the TIMIT dataset. For instance, see the following configuration file:
cfg/TIMIT_baselines/TIMIT_MLP_fbank_autoencoder.cfg
Our inputs are the standard 40-dimensional fbank coefficients that are gathered using a context windows of 11 frames (ie, the total dimensionality of our input is 440). A feed-forward neural network (called MLP_encoder) encodes our features into a 100-dimensional representation. The decoder (called MLP_decoder) is fed by the learned representations and tries to reconstruct the output. The system is trained with Mean Squared Error (MSE) metric. Note that in the [Model] section we added this line “err_final=cost_err(dec_out,lab_cd)” at the end. The current version of the model, in fact, by default needs that at least one label is specified (we will remove this limit in the next version).
You can train the system running the following command:
python run_exp.py cfg/TIMIT_baselines/TIMIT_MLP_fbank_autoencoder.cfg
The results should look like this:
ep=000 tr=['TIMIT_tr'] loss=0.139 err=0.999 valid=TIMIT_dev loss=0.076 err=1.000 lr_architecture1=0.080000 lr_architecture2=0.080000 time(s)=41
ep=001 tr=['TIMIT_tr'] loss=0.098 err=0.999 valid=TIMIT_dev loss=0.062 err=1.000 lr_architecture1=0.080000 lr_architecture2=0.080000 time(s)=39
ep=002 tr=['TIMIT_tr'] loss=0.091 err=0.999 valid=TIMIT_dev loss=0.058 err=1.000 lr_architecture1=0.040000 lr_architecture2=0.040000 time(s)=39
ep=003 tr=['TIMIT_tr'] loss=0.088 err=0.999 valid=TIMIT_dev loss=0.056 err=1.000 lr_architecture1=0.020000 lr_architecture2=0.020000 time(s)=38
ep=004 tr=['TIMIT_tr'] loss=0.087 err=0.999 valid=TIMIT_dev loss=0.055 err=0.999 lr_architecture1=0.010000 lr_architecture2=0.010000 time(s)=39
ep=005 tr=['TIMIT_tr'] loss=0.086 err=0.999 valid=TIMIT_dev loss=0.054 err=1.000 lr_architecture1=0.005000 lr_architecture2=0.005000 time(s)=39
ep=006 tr=['TIMIT_tr'] loss=0.086 err=0.999 valid=TIMIT_dev loss=0.054 err=1.000 lr_architecture1=0.002500 lr_architecture2=0.002500 time(s)=39
ep=007 tr=['TIMIT_tr'] loss=0.086 err=0.999 valid=TIMIT_dev loss=0.054 err=1.000 lr_architecture1=0.001250 lr_architecture2=0.001250 time(s)=39
ep=008 tr=['TIMIT_tr'] loss=0.086 err=0.999 valid=TIMIT_dev loss=0.054 err=0.999 lr_architecture1=0.000625 lr_architecture2=0.000625 time(s)=41
ep=009 tr=['TIMIT_tr'] loss=0.086 err=0.999 valid=TIMIT_dev loss=0.054 err=0.999 lr_architecture1=0.000313 lr_architecture2=0.000313 time(s)=38
You should only consider the field "loss=". The filed "err=" only contains not useuful information in this case (for the aforementioned reason). You can take a look into the generated features typing the following command:
copy-feats ark:exp/TIMIT_MLP_fbank_autoencoder/exp_files/forward_TIMIT_test_ep009_ck00_enc_out.ark ark,t:- | more
[1] M. Ravanelli, T. Parcollet, Y. Bengio, "The PyTorch-Kaldi Speech Recognition Toolkit", ArxIv
[2] M. Ravanelli, P. Brakel, M. Omologo, Y. Bengio, "Improving speech recognition by revising gated recurrent units", in Proceedings of Interspeech 2017. ArXiv
[3] M. Ravanelli, P. Brakel, M. Omologo, Y. Bengio, "Light Gated Recurrent Units for Speech Recognition", in IEEE Transactions on Emerging Topics in Computational Intelligence. ArXiv
[4] M. Ravanelli, "Deep Learning for Distant Speech Recognition", PhD Thesis, Unitn 2017. ArXiv
[5] T. Parcollet, M. Ravanelli, M. Morchid, G. Linarès, C. Trabelsi, R. De Mori, Y. Bengio, "Quaternion Recurrent Neural Networks", in Proceedings of ICLR 2019 ArXiv
[6] T. Parcollet, M. Morchid, G. Linarès, R. De Mori, "Bidirectional Quaternion Long-Short Term Memory Recurrent Neural Networks for Speech Recognition", in Proceedings of ICASSP 2019 ArXiv