#!/usr/bin/env bash # fix segmentation fault reported in https://github.com/k2-fsa/icefall/issues/674 export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python set -eou pipefail nj=15 stage=4 stop_stage=4 # We assume dl_dir (download dir) contains the following # directories and files. If not, they will be downloaded # by this script automatically. # # - $dl_dir/icmcasr # You can find data_icmcasr, resource_icmcasr inside it. # You can download them from https://www.openslr.org/33 # # - $dl_dir/musan # This directory contains the following directories downloaded from # http://www.openslr.org/17/ # # - music # - noise # - speech # ln -s /your/parent/path/to/ICMC-ASR $PWD/downloa dl_dir=$PWD/download . shared/parse_options.sh || exit 1 # vocab size for sentence piece models. # It will generate data/lang_bbpe_xxx, # data/lang_bbpe_yyy if the array contains xxx, yyy vocab_sizes=( # 2000 # 1000 500 ) # All files generated by this script are saved in "data". # You can safely remove "data" and rerun this script to regenerate it. mkdir -p data log() { # This function is from espnet local fname=${BASH_SOURCE[1]##*/} echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*" } log "dl_dir: $dl_dir" if [ $stage -le 1 ] && [ $stop_stage -ge 1 ]; then log "Stage 1: Prepare icmcasr manifest" # We assume that you have downloaded the icmcasr corpus # to $dl_dir/icmcasr if [ ! -f data/manifests/.icmcasr_manifests.done ]; then mkdir -p data/manifests for part in ihm sdm mdm; do lhotse prepare icmcasr --mic ${part} $dl_dir/ICMC-ASR data/manifests done touch data/manifests/.icmcasr_manifests.done fi fi if [ $stage -le 2 ] && [ $stop_stage -ge 2 ]; then log "Stage 2: Prepare musan manifest" # We assume that you have downloaded the musan corpus # to data/musan if [ ! -f data/manifests/.musan_manifests.done ]; then mkdir -p data/manifests lhotse prepare musan $dl_dir/musan data/manifests touch data/manifests/.musan_manifests.done fi fi if [ $stage -le 3 ] && [ $stop_stage -ge 3 ]; then log "Stage 3: Apply GSS enhancement on MDM data (this stage requires a GPU)" # We assume that you have installed the GSS package: https://github.com/desh2608/gss local/prepare_icmc_gss.sh --stage 1 --stop_stage 6 data/manifests exp/icmc_gss fi if [ $stage -le 4 ] && [ $stop_stage -ge 4 ]; then log "Stage 4: Compute fbank for icmcasr" if [ ! -f data/fbank/.icmcasr.done ]; then mkdir -p data/fbank ./local/compute_fbank_icmcasr.py --perturb-speed True echo "Combining manifests" lhotse combine data/manifests/cuts_train_{ihm,ihm_rvb,sdm,gss}.jsonl.gz - | shuf |\ gzip -c > data/manifests/cuts_train_all.jsonl.gz touch data/fbank/.icmcasr.done fi fi if [ $stage -le 5 ] && [ $stop_stage -ge 5 ]; then log "Stage 5: Compute fbank for musan" if [ ! -f data/fbank/.msuan.done ]; then mkdir -p data/fbank ./local/compute_fbank_musan.py touch data/fbank/.msuan.done fi fi lang_phone_dir=data/lang_phone if [ $stage -le 6 ] && [ $stop_stage -ge 6 ]; then log "Stage 6: Prepare G.fst" mkdir -p $lang_phone_dir (echo '!SIL SIL'; echo ' SPN'; echo ' SPN'; ) | cat - $dl_dir/icmcasr/resource_icmcasr/lexicon.txt | sort | uniq > $lang_phone_dir/lexicon.txt ./local/generate_unique_lexicon.py --lang-dir $lang_phone_dir if [ ! -f $lang_phone_dir/L_disambig.pt ]; then ./local/prepare_lang.py --lang-dir $lang_phone_dir fi fi