-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Minor fix to conformer-mmi * Minor fixes * Fix decode.py * add training files * train with ctc warmup * add pruned_transducer_stateless7_mmi * add zipformer_mmi/mmi_decode.py, using HP as decoding graph * add mmi_decode.py * remove pruned_transducer_stateless7_mmi * rename zipformer_mmi/train_with_ctc.py as zipformer_mmi/train.py * remove unused method * rename mmi_decode.py * add export.py pretrained.py jit_pretrained.py ... * add RESULTS.md * add CI test * add docs * add README.md Co-authored-by: pkufool <[email protected]>
- Loading branch information
1 parent
e83409c
commit b25c234
Showing
34 changed files
with
4,224 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
.github/scripts/run-librispeech-zipformer-mmi-2022-12-08.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
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]}) $*" | ||
} | ||
|
||
cd egs/librispeech/ASR | ||
|
||
repo_url=https://huggingface.co/Zengwei/icefall-asr-librispeech-zipformer-mmi-2022-12-08 | ||
|
||
log "Downloading pre-trained model from $repo_url" | ||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url | ||
repo=$(basename $repo_url) | ||
|
||
log "Display test files" | ||
tree $repo/ | ||
soxi $repo/test_wavs/*.wav | ||
ls -lh $repo/test_wavs/*.wav | ||
|
||
pushd $repo/exp | ||
git lfs pull --include "data/lang_bpe_500/3gram.pt" | ||
git lfs pull --include "data/lang_bpe_500/4gram.pt" | ||
git lfs pull --include "data/lang_bpe_500/L.pt" | ||
git lfs pull --include "data/lang_bpe_500/LG.pt" | ||
git lfs pull --include "data/lang_bpe_500/Linv.pt" | ||
git lfs pull --include "data/lang_bpe_500/bpe.model" | ||
git lfs pull --include "exp/cpu_jit.pt" | ||
git lfs pull --include "exp/pretrained.pt" | ||
ln -s pretrained.pt epoch-99.pt | ||
ls -lh *.pt | ||
popd | ||
|
||
log "Export to torchscript model" | ||
./zipformer_mmi/export.py \ | ||
--exp-dir $repo/exp \ | ||
--use-averaged-model false \ | ||
--bpe-model $repo/data/lang_bpe_500/bpe.model \ | ||
--epoch 99 \ | ||
--avg 1 \ | ||
--jit 1 | ||
|
||
ls -lh $repo/exp/*.pt | ||
|
||
log "Decode with models exported by torch.jit.script()" | ||
|
||
./zipformer_mmi/jit_pretrained.py \ | ||
--bpe-model $repo/data/lang_bpe_500/bpe.model \ | ||
--nn-model-filename $repo/exp/cpu_jit.pt \ | ||
--lang-dir $repo/data/lang_bpe_500 \ | ||
$repo/test_wavs/1089-134686-0001.wav \ | ||
$repo/test_wavs/1221-135766-0001.wav \ | ||
$repo/test_wavs/1221-135766-0002.wav | ||
|
||
for method in 1best nbest nbest-rescoring-LG nbest-rescoring-3-gram nbest-rescoring-4-gram; do | ||
log "$method" | ||
|
||
./zipformer_mmi/pretrained.py \ | ||
--method $method \ | ||
--checkpoint $repo/exp/pretrained.pt \ | ||
--lang-dir $repo/data/lang_bpe_500 \ | ||
--bpe-model $repo/data/lang_bpe_500/bpe.model \ | ||
$repo/test_wavs/1089-134686-0001.wav \ | ||
$repo/test_wavs/1221-135766-0001.wav \ | ||
$repo/test_wavs/1221-135766-0002.wav | ||
done | ||
|
||
|
||
echo "GITHUB_EVENT_NAME: ${GITHUB_EVENT_NAME}" | ||
echo "GITHUB_EVENT_LABEL_NAME: ${GITHUB_EVENT_LABEL_NAME}" | ||
if [[ x"${GITHUB_EVENT_NAME}" == x"schedule" || x"${GITHUB_EVENT_LABEL_NAME}" == x"run-decode" ]]; then | ||
mkdir -p zipformer_mmi/exp | ||
ln -s $PWD/$repo/exp/pretrained.pt zipformer_mmi/exp/epoch-999.pt | ||
ln -s $PWD/$repo/data/lang_bpe_500 data/ | ||
|
||
ls -lh data | ||
ls -lh zipformer_mmi/exp | ||
|
||
log "Decoding test-clean and test-other" | ||
|
||
# use a small value for decoding with CPU | ||
max_duration=100 | ||
|
||
for method in 1best nbest nbest-rescoring-LG nbest-rescoring-3-gram nbest-rescoring-4-gram; do | ||
log "Decoding with $method" | ||
|
||
./zipformer_mmi/decode.py \ | ||
--decoding-method $method \ | ||
--epoch 999 \ | ||
--avg 1 \ | ||
--use-averaged-model 0 \ | ||
--nbest-scale 1.2 \ | ||
--hp-scale 1.0 \ | ||
--max-duration $max_duration \ | ||
--lang-dir $repo/data/lang_bpe_500 \ | ||
--exp-dir zipformer_mmi/exp | ||
done | ||
|
||
rm zipformer_mmi/exp/*.pt | ||
fi |
167 changes: 167 additions & 0 deletions
167
.github/workflows/run-librispeech-2022-12-08-zipformer-mmi.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
# Copyright 2022 Zengwei Yao | ||
|
||
# See ../../LICENSE for clarification regarding multiple authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
name: run-librispeech-2022-12-08-zipformer-mmi | ||
# zipformer | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [labeled] | ||
|
||
schedule: | ||
# minute (0-59) | ||
# hour (0-23) | ||
# day of the month (1-31) | ||
# month (1-12) | ||
# day of the week (0-6) | ||
# nightly build at 15:50 UTC time every day | ||
- cron: "50 15 * * *" | ||
|
||
concurrency: | ||
group: run_librispeech_2022_12_08_zipformer-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
run_librispeech_2022_12_08_zipformer: | ||
if: github.event.label.name == 'ready' || github.event.label.name == 'run-decode' || github.event_name == 'push' || github.event_name == 'schedule' | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
python-version: [3.8] | ||
|
||
fail-fast: false | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
cache-dependency-path: '**/requirements-ci.txt' | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
grep -v '^#' ./requirements-ci.txt | xargs -n 1 -L 1 pip install | ||
pip uninstall -y protobuf | ||
pip install --no-binary protobuf protobuf | ||
- name: Cache kaldifeat | ||
id: my-cache | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/tmp/kaldifeat | ||
key: cache-tmp-${{ matrix.python-version }}-2022-09-25 | ||
|
||
- name: Install kaldifeat | ||
if: steps.my-cache.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
.github/scripts/install-kaldifeat.sh | ||
- name: Cache LibriSpeech test-clean and test-other datasets | ||
id: libri-test-clean-and-test-other-data | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/tmp/download | ||
key: cache-libri-test-clean-and-test-other | ||
|
||
- name: Download LibriSpeech test-clean and test-other | ||
if: steps.libri-test-clean-and-test-other-data.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
.github/scripts/download-librispeech-test-clean-and-test-other-dataset.sh | ||
- name: Prepare manifests for LibriSpeech test-clean and test-other | ||
shell: bash | ||
run: | | ||
.github/scripts/prepare-librispeech-test-clean-and-test-other-manifests.sh | ||
- name: Cache LibriSpeech test-clean and test-other fbank features | ||
id: libri-test-clean-and-test-other-fbank | ||
uses: actions/cache@v2 | ||
with: | ||
path: | | ||
~/tmp/fbank-libri | ||
key: cache-libri-fbank-test-clean-and-test-other-v2 | ||
|
||
- name: Compute fbank for LibriSpeech test-clean and test-other | ||
if: steps.libri-test-clean-and-test-other-fbank.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
.github/scripts/compute-fbank-librispeech-test-clean-and-test-other.sh | ||
- name: Inference with pre-trained model | ||
shell: bash | ||
env: | ||
GITHUB_EVENT_NAME: ${{ github.event_name }} | ||
GITHUB_EVENT_LABEL_NAME: ${{ github.event.label.name }} | ||
run: | | ||
mkdir -p egs/librispeech/ASR/data | ||
ln -sfv ~/tmp/fbank-libri egs/librispeech/ASR/data/fbank | ||
ls -lh egs/librispeech/ASR/data/* | ||
sudo apt-get -qq install git-lfs tree sox | ||
export PYTHONPATH=$PWD:$PYTHONPATH | ||
export PYTHONPATH=~/tmp/kaldifeat/kaldifeat/python:$PYTHONPATH | ||
export PYTHONPATH=~/tmp/kaldifeat/build/lib:$PYTHONPATH | ||
.github/scripts/run-librispeech-zipformer-mmi-2022-12-08.sh | ||
- name: Display decoding results for librispeech zipformer-mmi | ||
if: github.event_name == 'schedule' || github.event.label.name == 'run-decode' | ||
shell: bash | ||
run: | | ||
cd egs/librispeech/ASR/ | ||
tree ./zipformer-mmi/exp | ||
cd zipformer-mmi | ||
echo "results for zipformer-mmi" | ||
echo "===1best===" | ||
find exp/1best -name "log-*" -exec grep -n --color "best for test-clean" {} + | sort -n -k2 | ||
find exp/1best -name "log-*" -exec grep -n --color "best for test-other" {} + | sort -n -k2 | ||
echo "===nbest===" | ||
find exp/nbest -name "log-*" -exec grep -n --color "best for test-clean" {} + | sort -n -k2 | ||
find exp/nbest -name "log-*" -exec grep -n --color "best for test-other" {} + | sort -n -k2 | ||
echo "===nbest-rescoring-LG===" | ||
find exp/nbest-rescoring-LG -name "log-*" -exec grep -n --color "best for test-clean" {} + | sort -n -k2 | ||
find exp/nbest-rescoring-LG -name "log-*" -exec grep -n --color "best for test-other" {} + | sort -n -k2 | ||
echo "===nbest-rescoring-3-gram===" | ||
find exp/nbest-rescoring-3-gram -name "log-*" -exec grep -n --color "best for test-clean" {} + | sort -n -k2 | ||
find exp/nbest-rescoring-3-gram -name "log-*" -exec grep -n --color "best for test-other" {} + | sort -n -k2 | ||
echo "===nbest-rescoring-4-gram===" | ||
find exp/nbest-rescoring-4-gram -name "log-*" -exec grep -n --color "best for test-clean" {} + | sort -n -k2 | ||
find exp/nbest-rescoring-4-gram -name "log-*" -exec grep -n --color "best for test-other" {} + | sort -n -k2 | ||
- name: Upload decoding results for librispeech zipformer-mmi | ||
uses: actions/upload-artifact@v2 | ||
if: github.event_name == 'schedule' || github.event.label.name == 'run-decode' | ||
with: | ||
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-ubuntu-18.04-cpu-zipformer_mmi-2022-12-08 | ||
path: egs/librispeech/ASR/zipformer_mmi/exp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ LibriSpeech | |
tdnn_lstm_ctc | ||
conformer_ctc | ||
lstm_pruned_stateless_transducer | ||
zipformer_mmi |
Oops, something went wrong.