|
| 1 | +# Copyright 2021 Fangjun Kuang (csukuangfj@gmail.com) |
| 2 | + |
| 3 | +# See ../../LICENSE for clarification regarding multiple authors |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +name: run-pre-trained-tranducer-stateless |
| 18 | + |
| 19 | +on: |
| 20 | + push: |
| 21 | + branches: |
| 22 | + - master |
| 23 | + pull_request: |
| 24 | + types: [labeled] |
| 25 | + |
| 26 | +jobs: |
| 27 | + run_pre_trained_transducer_stateless: |
| 28 | + if: github.event.label.name == 'ready' || github.event_name == 'push' |
| 29 | + runs-on: ${{ matrix.os }} |
| 30 | + strategy: |
| 31 | + matrix: |
| 32 | + os: [ubuntu-18.04] |
| 33 | + python-version: [3.7, 3.8, 3.9] |
| 34 | + torch: ["1.10.0"] |
| 35 | + torchaudio: ["0.10.0"] |
| 36 | + k2-version: ["1.9.dev20211101"] |
| 37 | + |
| 38 | + fail-fast: false |
| 39 | + |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v2 |
| 42 | + with: |
| 43 | + fetch-depth: 0 |
| 44 | + |
| 45 | + - name: Setup Python ${{ matrix.python-version }} |
| 46 | + uses: actions/setup-python@v1 |
| 47 | + with: |
| 48 | + python-version: ${{ matrix.python-version }} |
| 49 | + |
| 50 | + - name: Install Python dependencies |
| 51 | + run: | |
| 52 | + python3 -m pip install --upgrade pip pytest |
| 53 | + # numpy 1.20.x does not support python 3.6 |
| 54 | + pip install numpy==1.19 |
| 55 | + pip install torch==${{ matrix.torch }}+cpu torchaudio==${{ matrix.torchaudio }}+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html |
| 56 | + pip install k2==${{ matrix.k2-version }}+cpu.torch${{ matrix.torch }} -f https://k2-fsa.org/nightly/ |
| 57 | +
|
| 58 | + python3 -m pip install git+https://github.com/lhotse-speech/lhotse |
| 59 | + python3 -m pip install kaldifeat |
| 60 | + # We are in ./icefall and there is a file: requirements.txt in it |
| 61 | + pip install -r requirements.txt |
| 62 | +
|
| 63 | + - name: Install graphviz |
| 64 | + shell: bash |
| 65 | + run: | |
| 66 | + python3 -m pip install -qq graphviz |
| 67 | + sudo apt-get -qq install graphviz |
| 68 | +
|
| 69 | + - name: Download pre-trained model |
| 70 | + shell: bash |
| 71 | + run: | |
| 72 | + sudo apt-get -qq install git-lfs tree sox |
| 73 | + cd egs/librispeech/ASR |
| 74 | + mkdir tmp |
| 75 | + cd tmp |
| 76 | + git lfs install |
| 77 | + git clone https://huggingface.co/csukuangfj/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22 |
| 78 | + cd .. |
| 79 | + tree tmp |
| 80 | + soxi tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/test_wavs/*.wav |
| 81 | + ls -lh tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/test_wavs/*.wav |
| 82 | +
|
| 83 | + - name: Run greedy search decoding |
| 84 | + shell: bash |
| 85 | + run: | |
| 86 | + export PYTHONPATH=$PWD:PYTHONPATH |
| 87 | + cd egs/librispeech/ASR |
| 88 | + ./transducer_stateless/pretrained.py \ |
| 89 | + --method greedy_search \ |
| 90 | + --checkpoint ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/exp/pretrained.pt \ |
| 91 | + --bpe-model ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/data/lang_bpe_500/bpe.model \ |
| 92 | + ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/test_wavs/1089-134686-0001.wav \ |
| 93 | + ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/test_wavs/1221-135766-0001.wav \ |
| 94 | + ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/test_wavs/1221-135766-0002.wav |
| 95 | +
|
| 96 | + - name: Run beam search decoding |
| 97 | + shell: bash |
| 98 | + run: | |
| 99 | + export PYTHONPATH=$PWD:$PYTHONPATH |
| 100 | + cd egs/librispeech/ASR |
| 101 | + ./transducer_stateless/pretrained.py \ |
| 102 | + --method beam_search \ |
| 103 | + --beam-size 4 \ |
| 104 | + --checkpoint ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/exp/pretrained.pt \ |
| 105 | + --bpe-model ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/data/lang_bpe_500/bpe.model \ |
| 106 | + ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/test_wavs/1089-134686-0001.wav \ |
| 107 | + ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/test_wavs/1221-135766-0001.wav \ |
| 108 | + ./tmp/icefall-asr-librispeech-transducer-stateless-bpe-500-2021-12-22/test_wavs/1221-135766-0002.wav |
0 commit comments