Step1 Data preparation
下載完數據后我們需要預處理數據使其格式能被wav2letter++處理:
cd wav2letter/tutorials/1-librispeech_clean
python3 prepare_data.py --src $W2LDIR/LibriSpeech/ --dst $W2LDIR
python3 prepare_lm.py --dst $W2LDIR
此時生成的data文件夾里存放著預處理后的數據。
prepare_data.py
prepares the dataset and tokens file
prepare_lm.py
prepares lexicon and language model data
預處理后的每條音頻數據都會有四個對應的文件:
-
.flac/.wav
audio file(e.g. 000000000.flac) -
.id
identifiers for the file(e.g. file_id 0) -
.wrd
words file containing the transcription(e.g. hello world) -
.tkn
tokens(graphemes) file(e.g. h e l l o | w o r l d, the symbol "|" is used to denote space)
Step 2: Training the Acoustic Model
首先將train.cfg
文件中的[...]
替換成正確的路徑
--datadir=/home/zd/W2Ldemo/
--tokensdir=/home/zd/W2Ldemo/
--rundir=/home/zd/W2Ldemo/saved_models
--archdir=/data/zd/wav2letter/tutorials/1-librispeech_clean/
然后執行:
/data/zd/wav2letter/build/Train train --flagsfile /data/zd/wav2letter/tutorials/1-librispeech_clean/train.cfg
訓練后的logs保存在你設置的rundir
目錄下。
Step3 Decoding
首先將decode.cfg
文件中的[...]
替換成正確的路徑
--datadir=/home/zd/W2Ldemo/
--lexicon=/home/zd/W2Ldemo/lm/lexicon.txt
--lm=/home/zd/W2Ldemo/lm/3-gram.arpa
--am=/home/zd/W2Ldemo/saved_models/librispeech_clean_trainlogs/001_model_data#dev-clean.bin
--sclite=/home/zd/W2Ldemo/decode_logs
然后執行:
/data/zd/wav2letter/build/Decoder --flagsfile /data/zd/wav2letter/tutorials/1-librispeech_clean/decode.cfg
解碼后的logs保存在你設置的sclite
目錄下,查看最后5行log:
tail -n 5 data#test-clean.log
|T|: then i long tried by natural ills received the comfort fast while budding at thy sight my pilgrim's staff gave out green leaves with morning dews impearled
|P|: then i long tried by natural walls were seized the comfort fast while buying at thy sight my pilgrim staff gave out relies with morning dew impearled
[sample: 2616, WER: 29.6296%, LER: 12.2581%, slice WER: 18.6255%, slice LER: 8.84388%, progress: 100%]
------
[Decode data/test-clean (2620 samples) in 113.572s (actual decoding time 0.205s/sample) -- WER: 18.6872, LER: 9.02497]
|T|
- True transcription
|P|
- predicted transcription.
WER
- Word Error Rate for current sample.
slice-WER
- Overall Word Error Rate in the current thread. (Note that for decoding they divide the work using a ThreadPool)
最后一行顯示最終的結果WER: 18.6872, LER: 9.02497