From bfa77040ca286112cb942434e38227a7a7273fe7 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 14 Oct 2021 20:20:35 +0800 Subject: [PATCH] Add CI to run pre-trained models. --- .github/workflows/run-pretrained.yml | 102 +++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/run-pretrained.yml diff --git a/.github/workflows/run-pretrained.yml b/.github/workflows/run-pretrained.yml new file mode 100644 index 000000000..6e37ae342 --- /dev/null +++ b/.github/workflows/run-pretrained.yml @@ -0,0 +1,102 @@ +# Copyright 2021 Fangjun Kuang (csukuangfj@gmail.com) + +# 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-pre-trained-conformer-ctc + +on: + push: + branches: + - master + - test-pretrained + pull_request: + types: [labeled] + +jobs: + run_pre_trained_conformer_ctc: + if: github.event.label.name == 'ready' || github.event_name == 'push' + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-18.04] + python-version: [3.6, 3.7, 3.8, 3.9] + torch: ["1.8.1"] + k2-version: ["1.9.dev20210919"] + + fail-fast: false + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + + - name: Install Python dependencies + run: | + python3 -m pip install --upgrade pip pytest + pip install k2==${{ matrix.k2-version }}+cpu.torch${{ matrix.torch }} -f https://k2-fsa.org/nightly/ + + python3 -m pip install git+https://github.com/lhotse-speech/lhotse + # We are in ./icefall and there is a file: requirements.txt in it + pip install -r requirements.txt + + - name: Install graphviz + if: startsWith(matrix.os, 'ubuntu') + shell: bash + run: | + python3 -m pip install -qq graphviz + sudo apt-get -qq install graphviz + + - name: Download pre-trained model + shell: bash + run: | + sudo apt-get -qq install git-lfs tree sox + cd egs/librispeech/ASR + mkdir tmp + cd tmp + git lfs install + git clone https://huggingface.co/pkufool/icefall_asr_librispeech_conformer_ctc + tree tmp + soxi tmp/icefall_asr_librispeech_conformer_ctc/test_wavs/*.flac + ls -lh icefall_asr_librispeech_conformer_ctc/*/* + + - name: Run CTC decoding + shell: bash + run: | + cd egs/librispeech/ASR + ./conformer_ctc/pretrained.py \ + --checkpoint ./tmp/icefall_asr_librispeech_conformer_ctc/exp/pretrained.pt \ + --lang-dir ./tmp/icefall_asr_librispeech_conformer_ctc/data/lang_bpe \ + --method ctc-decoding \ + ./tmp/icefall_asr_librispeech_conformer_ctc/test_wavs/1089-134686-0001.flac \ + ./tmp/icefall_asr_librispeech_conformer_ctc/test_wavs/1221-135766-0001.flac \ + ./tmp/icefall_asr_librispeech_conformer_ctc/test_wavs/1221-135766-0002.flac + + - name: Run HLG decoding + shell: bash + run: | + cd egs/librispeech/ASR + ./conformer_ctc/pretrained.py \ + --checkpoint ./tmp/icefall_asr_librispeech_conformer_ctc/exp/pretrained.pt \ + --lang-dir ./tmp/icefall_asr_librispeech_conformer_ctc/data/lang_bpe \ + ./tmp/icefall_asr_librispeech_conformer_ctc/test_wavs/1089-134686-0001.flac \ + ./tmp/icefall_asr_librispeech_conformer_ctc/test_wavs/1221-135766-0001.flac \ + ./tmp/icefall_asr_librispeech_conformer_ctc/test_wavs/1221-135766-0002.flac + +