Skip to content

Commit

Permalink
Merge pull request #4592 from brianyan918/egs2_aesrc
Browse files Browse the repository at this point in the history
Egs2 aesrc
  • Loading branch information
ftshijt committed Aug 22, 2022
2 parents a65cc78 + 1617a49 commit f274ebe
Show file tree
Hide file tree
Showing 36 changed files with 540 additions and 0 deletions.
1 change: 1 addition & 0 deletions egs2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ See: https://espnet.github.io/espnet/espnet2_tutorial.html#recipes-using-espnet2

| Directory name | Corpus name | Task | Language | URL | Note |
|-------------------------|----------------------------------------------------------------------------------------------------------------------------------|-------------------------| --------------------- | ------------------------------------------------------------------------------------------------------------ | ------------ |
| aesrc2020 | Accented English Speech Recognition Challenge 2020 | ASR | ENG | https://arxiv.org/abs/2102.10233 | |
| aidatatang_200zh | Aidatatang_200zh A free Chinese Mandarin speech corpus | ASR | CMN | http://www.openslr.org/resources/62 | |
| aishell | AISHELL-ASR0009-OS1 Open Source Mandarin Speech Corpus | ASR | CMN | http://www.aishelltech.com/kysjcp | |
| aishell2 | AISHELL-2 Open Source Mandarin Speech Corpus | ASR | CMN | https://www.aishelltech.com/aishell_2 | |
Expand Down
34 changes: 34 additions & 0 deletions egs2/aesrc2020/asr1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!-- Generated by scripts/utils/show_asr_result.sh -->
# RESULTS
## Environments
- date: `Sat Aug 20 06:55:57 EDT 2022`
- python version: `3.8.13 (default, Mar 28 2022, 11:38:47) [GCC 7.5.0]`
- espnet version: `espnet 202207`
- pytorch version: `pytorch 1.8.1`
- Git hash: `c892feb2ba248c85b683bf3cdef6c8f7ce85449a`
- Commit date: `Thu Aug 18 11:54:56 2022 -0400`

## asr_train_asr_raw_en_bpe5000_sp

- Model link: [huggingface](https://huggingface.co/espnet/brianyan918_aesrc2020_asr_conformer)
- ASR config: [./conf/train_asr.yaml](./conf/train_asr.yaml)
- Inference config: [./conf/decode_asr.yaml](./conf/decode_asr.yaml)

### WER

|dataset|Snt|Wrd|Corr|Sub|Del|Ins|Err|S.Err|
|---|---|---|---|---|---|---|---|---|
|decode_asr_asr_model_valid.acc.ave/test|15299|146813|94.8|4.7|0.6|0.7|5.9|31.9|

### CER

|dataset|Snt|Wrd|Corr|Sub|Del|Ins|Err|S.Err|
|---|---|---|---|---|---|---|---|---|
|decode_asr_asr_model_valid.acc.ave/test|15299|708064|97.9|1.2|0.9|0.7|2.8|31.9|

### TER

|dataset|Snt|Wrd|Corr|Sub|Del|Ins|Err|S.Err|
|---|---|---|---|---|---|---|---|---|
|decode_asr_asr_model_valid.acc.ave/test|15299|165136|93.2|4.3|2.6|0.6|7.4|31.9|

1 change: 1 addition & 0 deletions egs2/aesrc2020/asr1/asr.sh
110 changes: 110 additions & 0 deletions egs2/aesrc2020/asr1/cmd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# ====== About run.pl, queue.pl, slurm.pl, and ssh.pl ======
# Usage: <cmd>.pl [options] JOB=1:<nj> <log> <command...>
# e.g.
# run.pl --mem 4G JOB=1:10 echo.JOB.log echo JOB
#
# Options:
# --time <time>: Limit the maximum time to execute.
# --mem <mem>: Limit the maximum memory usage.
# -–max-jobs-run <njob>: Limit the number parallel jobs. This is ignored for non-array jobs.
# --num-threads <ngpu>: Specify the number of CPU core.
# --gpu <ngpu>: Specify the number of GPU devices.
# --config: Change the configuration file from default.
#
# "JOB=1:10" is used for "array jobs" and it can control the number of parallel jobs.
# The left string of "=", i.e. "JOB", is replaced by <N>(Nth job) in the command and the log file name,
# e.g. "echo JOB" is changed to "echo 3" for the 3rd job and "echo 8" for 8th job respectively.
# Note that the number must start with a positive number, so you can't use "JOB=0:10" for example.
#
# run.pl, queue.pl, slurm.pl, and ssh.pl have unified interface, not depending on its backend.
# These options are mapping to specific options for each backend and
# it is configured by "conf/queue.conf" and "conf/slurm.conf" by default.
# If jobs failed, your configuration might be wrong for your environment.
#
#
# The official documentation for run.pl, queue.pl, slurm.pl, and ssh.pl:
# "Parallelization in Kaldi": http://kaldi-asr.org/doc/queue.html
# =========================================================~


# Select the backend used by run.sh from "local", "stdout", "sge", "slurm", or "ssh"
cmd_backend='local'

# Local machine, without any Job scheduling system
if [ "${cmd_backend}" = local ]; then

# The other usage
export train_cmd="run.pl"
# Used for "*_train.py": "--gpu" is appended optionally by run.sh
export cuda_cmd="run.pl"
# Used for "*_recog.py"
export decode_cmd="run.pl"

# Local machine logging to stdout and log file, without any Job scheduling system
elif [ "${cmd_backend}" = stdout ]; then

# The other usage
export train_cmd="stdout.pl"
# Used for "*_train.py": "--gpu" is appended optionally by run.sh
export cuda_cmd="stdout.pl"
# Used for "*_recog.py"
export decode_cmd="stdout.pl"


# "qsub" (Sun Grid Engine, or derivation of it)
elif [ "${cmd_backend}" = sge ]; then
# The default setting is written in conf/queue.conf.
# You must change "-q g.q" for the "queue" for your environment.
# To know the "queue" names, type "qhost -q"
# Note that to use "--gpu *", you have to setup "complex_value" for the system scheduler.

export train_cmd="queue.pl"
export cuda_cmd="queue.pl"
export decode_cmd="queue.pl"


# "qsub" (Torque/PBS.)
elif [ "${cmd_backend}" = pbs ]; then
# The default setting is written in conf/pbs.conf.

export train_cmd="pbs.pl"
export cuda_cmd="pbs.pl"
export decode_cmd="pbs.pl"


# "sbatch" (Slurm)
elif [ "${cmd_backend}" = slurm ]; then
# The default setting is written in conf/slurm.conf.
# You must change "-p cpu" and "-p gpu" for the "partition" for your environment.
# To know the "partion" names, type "sinfo".
# You can use "--gpu * " by default for slurm and it is interpreted as "--gres gpu:*"
# The devices are allocated exclusively using "${CUDA_VISIBLE_DEVICES}".

export train_cmd="slurm.pl"
export cuda_cmd="slurm.pl"
export decode_cmd="slurm.pl"

elif [ "${cmd_backend}" = ssh ]; then
# You have to create ".queue/machines" to specify the host to execute jobs.
# e.g. .queue/machines
# host1
# host2
# host3
# Assuming you can login them without any password, i.e. You have to set ssh keys.

export train_cmd="ssh.pl"
export cuda_cmd="ssh.pl"
export decode_cmd="ssh.pl"

# This is an example of specifying several unique options in the JHU CLSP cluster setup.
# Users can modify/add their own command options according to their cluster environments.
elif [ "${cmd_backend}" = jhu ]; then

export train_cmd="queue.pl --mem 2G"
export cuda_cmd="queue-freegpu.pl --mem 2G --gpu 1 --config conf/queue.conf"
export decode_cmd="queue.pl --mem 4G"

else
echo "$0: Error: Unknown cmd_backend=${cmd_backend}" 1>&2
return 1
fi
6 changes: 6 additions & 0 deletions egs2/aesrc2020/asr1/conf/decode_asr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
beam_size: 20
ctc_weight: 0.3
lm_weight: 0.0
maxlenratio: 0.0
minlenratio: 0.0
penalty: 0.0
2 changes: 2 additions & 0 deletions egs2/aesrc2020/asr1/conf/fbank.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--sample-frequency=16000
--num-mel-bins=80
11 changes: 11 additions & 0 deletions egs2/aesrc2020/asr1/conf/pbs.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Default configuration
command qsub -V -v PATH -S /bin/bash
option name=* -N $0
option mem=* -l mem=$0
option mem=0 # Do not add anything to qsub_opts
option num_threads=* -l ncpus=$0
option num_threads=1 # Do not add anything to qsub_opts
option num_nodes=* -l nodes=$0:ppn=1
default gpu=0
option gpu=0
option gpu=* -l ngpus=$0
1 change: 1 addition & 0 deletions egs2/aesrc2020/asr1/conf/pitch.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--sample-frequency=16000
12 changes: 12 additions & 0 deletions egs2/aesrc2020/asr1/conf/queue.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Default configuration
command qsub -v PATH -cwd -S /bin/bash -j y -l arch=*64*
option name=* -N $0
option mem=* -l mem_free=$0,ram_free=$0
option mem=0 # Do not add anything to qsub_opts
option num_threads=* -pe smp $0
option num_threads=1 # Do not add anything to qsub_opts
option max_jobs_run=* -tc $0
option num_nodes=* -pe mpi $0 # You must set this PE as allocation_rule=1
default gpu=0
option gpu=0
option gpu=* -l gpu=$0 -q g.q
14 changes: 14 additions & 0 deletions egs2/aesrc2020/asr1/conf/slurm.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Default configuration
command sbatch --export=PATH
option name=* --job-name $0
option time=* --time $0
option mem=* --mem-per-cpu $0
option mem=0
option num_threads=* --cpus-per-task $0
option num_threads=1 --cpus-per-task 1
option num_nodes=* --nodes $0
default gpu=0
option gpu=0 -p cpu
option gpu=* -p gpu --gres=gpu:$0 -c $0 # Recommend allocating more CPU than, or equal to the number of GPU
# note: the --max-jobs-run option is supported as a special case
# by slurm.pl and you don't have to handle it in the config file.
1 change: 1 addition & 0 deletions egs2/aesrc2020/asr1/conf/train_asr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
encoder: conformer
encoder_conf:
output_size: 256
attention_heads: 4
linear_units: 1024
num_blocks: 12
dropout_rate: 0.1
positional_dropout_rate: 0.1
attention_dropout_rate: 0.1
input_layer: conv2d
normalize_before: true
macaron_style: true
rel_pos_type: latest
pos_enc_layer_type: rel_pos
selfattention_layer_type: rel_selfattn
activation_type: swish
use_cnn_module: true
cnn_module_kernel: 31

decoder: transformer
decoder_conf:
attention_heads: 4
linear_units: 2048
num_blocks: 6
dropout_rate: 0.1
positional_dropout_rate: 0.1
self_attention_dropout_rate: 0.1
src_attention_dropout_rate: 0.1

model_conf:
ctc_weight: 0.3
lsm_weight: 0.1
length_normalized_loss: false

frontend_conf:
n_fft: 512
win_length: 400
hop_length: 160

seed: 2022
log_interval: 400
num_att_plot: 0
num_workers: 4
sort_in_batch: descending # how to sort data in making batch
sort_batch: descending # how to sort created batches
batch_type: numel
batch_bins: 16000000
accum_grad: 4
max_epoch: 70
patience: none
init: none
best_model_criterion:
- - valid
- acc
- max
keep_nbest_models: 10

use_amp: true
cudnn_deterministic: false
cudnn_benchmark: false

optim: adam
optim_conf:
lr: 0.002
weight_decay: 0.000001
scheduler: warmuplr
scheduler_conf:
warmup_steps: 15000

specaug: specaug
specaug_conf:
apply_time_warp: true
time_warp_window: 5
time_warp_mode: bicubic
apply_freq_mask: true
freq_mask_width_range:
- 0
- 27
num_freq_mask: 2
apply_time_mask: true
time_mask_width_ratio_range:
- 0.
- 0.05
num_time_mask: 5
1 change: 1 addition & 0 deletions egs2/aesrc2020/asr1/db.sh
24 changes: 24 additions & 0 deletions egs2/aesrc2020/asr1/local/create_subsets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

. ./path.sh || exit 1;
. ./cmd.sh || exit 1;

data=$1 # data transformed into kaldi format
recog_set=$2

# divide development set for cross validation
if [ -d ${data} ];then
for i in ${recog_set};do
./utils/subset_data_dir.sh --spk-list local/files/cvlist/${i}_cv_spk $data/data_all $data/cv/$i
cat $data/cv/$i/wav.scp >> $data/cv.scp
done
./utils/filter_scp.pl --exclude $data/cv.scp $data/data_all/wav.scp > $data/train_and_dev.scp
#95-5 split for dev set
sed -n '0~20p' $data/train_and_dev.scp > $data/dev.scp
./utils/filter_scp.pl --exclude $data/dev.scp $data/train_and_dev.scp > $data/train.scp
./utils/subset_data_dir.sh --utt-list $data/train.scp $data/data_all $data/train
./utils/subset_data_dir.sh --utt-list $data/dev.scp $data/data_all $data/valid
./utils/subset_data_dir.sh --utt-list $data/cv.scp $data/data_all $data/test
fi

echo "local/subset_data.sh succeeded"
57 changes: 57 additions & 0 deletions egs2/aesrc2020/asr1/local/data.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env bash
# Set bash to 'debug' mode, it will exit on :
# -e 'error', -u 'undefined variable', -o ... 'error in pipeline', -x 'print commands',
set -e
set -u
set -o pipefail

log() {
local fname=${BASH_SOURCE[1]##*/}
echo -e "$(date '+%Y-%m-%dT%H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
}
SECONDS=0

stage=1
stop_stage=100000

recog_set="US UK IND CHN JPN PT RU KR CA ES"

log "$0 $*"
. utils/parse_options.sh

. ./db.sh
. ./path.sh
. ./cmd.sh


if [ $# -ne 0 ]; then
log "Error: No positional arguments are required."
exit 2
fi

if [ -z "${AESRC2020}" ]; then
log "Fill the value of 'AESRC2020' of db.sh" # place datatang.zip in this dir
exit 1
fi

if [ ${stage} -le 1 ] && [ ${stop_stage} -ge 1 ]; then
if [ ! -d "${AESRC2020}/Datatang-English/data" ]; then
echo "Data Download to ${AESRC2020}"
if [ ! -f "${AESRC2020}/datatang.zip" ]; then
echo "The AESRC2020 data needs to be requested via services@datatang.com"
exit 1
fi
local/download_and_untar.sh ${AESRC2020}/datatang.zip ${AESRC2020}
else
log "stage 1: ${AESRC2020}/Datatang-English/data is already existing. Skip data downloading"
fi
fi

if [ ${stage} -le 2 ] && [ ${stop_stage} -ge 2 ]; then
echo "Data preparation"
local/data_prep.sh ${AESRC2020}/Datatang-English/data data
./utils/fix_data_dir.sh data/data_all
local/create_subsets.sh data "${recog_set}"
fi

log "Successfully finished. [elapsed=${SECONDS}s]"

0 comments on commit f274ebe

Please sign in to comment.