Blame view
egs/aidatatang_200zh/s5/local/data_prep.sh
2.14 KB
8dcb6dfcb first commit |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
#!/bin/bash # Copyright 2017 Xingyu Na # Apache 2.0 . ./path.sh || exit 1; if [ $# != 2 ]; then echo "Usage: $0 <corpus-path> <text-path>" echo " $0 /export/a05/xna/data/data_aidatatang_200zh/corpus /export/a05/xna/data/data_aidatatang_200zh/transcript" exit 1; fi aidatatang_audio_dir=$1 aidatatang_text=$2/aidatatang_200_zh_transcript.txt train_dir=data/local/train dev_dir=data/local/dev test_dir=data/local/test tmp_dir=data/local/tmp mkdir -p $train_dir mkdir -p $dev_dir mkdir -p $test_dir mkdir -p $tmp_dir # data directory check if [ ! -d $aidatatang_audio_dir ] || [ ! -f $aidatatang_text ]; then echo "Error: $0 requires two directory arguments" exit 1; fi # find wav audio file for train, dev and test resp. find $aidatatang_audio_dir -iname "*.wav" > $tmp_dir/wav.flist n=`cat $tmp_dir/wav.flist | wc -l` [ $n -ne 237265 ] && \ echo Warning: expected 237265 data files, found $n grep -i "corpus/train" $tmp_dir/wav.flist > $train_dir/wav.flist || exit 1; grep -i "corpus/dev" $tmp_dir/wav.flist > $dev_dir/wav.flist || exit 1; grep -i "corpus/test" $tmp_dir/wav.flist > $test_dir/wav.flist || exit 1; rm -r $tmp_dir # Transcriptions preparation for dir in $train_dir $dev_dir $test_dir; do echo Preparing $dir transcriptions sed -e 's/\.wav//' $dir/wav.flist | awk -F '/' '{print $NF}' > $dir/utt.list sed -e 's/\.wav//' $dir/wav.flist | awk -F '/' '{i=NF-1;printf("%s %s ",$NF,$i)}' > $dir/utt2spk_all paste -d' ' $dir/utt.list $dir/wav.flist > $dir/wav.scp_all utils/filter_scp.pl -f 1 $dir/utt.list $aidatatang_text > $dir/transcripts.txt awk '{print $1}' $dir/transcripts.txt > $dir/utt.list utils/filter_scp.pl -f 1 $dir/utt.list $dir/utt2spk_all | sort -u > $dir/utt2spk utils/filter_scp.pl -f 1 $dir/utt.list $dir/wav.scp_all | sort -u > $dir/wav.scp sort -u $dir/transcripts.txt > $dir/text utils/utt2spk_to_spk2utt.pl $dir/utt2spk > $dir/spk2utt done mkdir -p data/train data/dev data/test for f in spk2utt utt2spk wav.scp text; do cp $train_dir/$f data/train/$f || exit 1; cp $dev_dir/$f data/dev/$f || exit 1; cp $test_dir/$f data/test/$f || exit 1; done echo "$0: aidatatang_200zh data preparation succeeded" exit 0; |