# 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-yesno-recipe on: push: branches: - master pull_request: branches: - master concurrency: group: run-yesno-recipe-${{ github.ref }} cancel-in-progress: true jobs: run-yesno-recipe: runs-on: ${{ matrix.os }} strategy: matrix: # os: [ubuntu-latest, macos-10.15] # TODO: enable macOS for CPU testing 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 libnsdfile and libsox if: startsWith(matrix.os, 'ubuntu') run: | sudo apt update sudo apt install -q -y libsndfile1-dev libsndfile1 ffmpeg sudo apt install -q -y --fix-missing sox libsox-dev libsox-fmt-all - 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==3.20.* pip install --no-deps --force-reinstall k2==1.24.4.dev20231021+cpu.torch1.13.1 -f https://k2-fsa.github.io/k2/cpu.html pip install kaldifeat==1.25.1.dev20231022+cpu.torch1.13.1 -f https://csukuangfj.github.io/kaldifeat/cpu.html - name: Run yesno recipe shell: bash working-directory: ${{github.workspace}} run: | export PYTHONPATH=$PWD:$PYTHONPATH echo $PYTHONPATH cd egs/yesno/ASR ./prepare.sh python3 ./tdnn/train.py python3 ./tdnn/decode.py - name: Test exporting to pretrained.pt shell: bash working-directory: ${{github.workspace}} run: | export PYTHONPATH=$PWD:$PYTHONPATH echo $PYTHONPATH cd egs/yesno/ASR python3 ./tdnn/export.py --epoch 14 --avg 2 python3 ./tdnn/pretrained.py \ --checkpoint ./tdnn/exp/pretrained.pt \ --HLG ./data/lang_phone/HLG.pt \ --words-file ./data/lang_phone/words.txt \ download/waves_yesno/0_0_0_1_0_0_0_1.wav \ download/waves_yesno/0_0_1_0_0_0_1_0.wav - name: Test exporting to torchscript shell: bash working-directory: ${{github.workspace}} run: | export PYTHONPATH=$PWD:$PYTHONPATH echo $PYTHONPATH cd egs/yesno/ASR python3 ./tdnn/export.py --epoch 14 --avg 2 --jit 1 python3 ./tdnn/jit_pretrained.py \ --nn-model ./tdnn/exp/cpu_jit.pt \ --HLG ./data/lang_phone/HLG.pt \ --words-file ./data/lang_phone/words.txt \ download/waves_yesno/0_0_0_1_0_0_0_1.wav \ download/waves_yesno/0_0_1_0_0_0_1_0.wav - name: Test exporting to onnx shell: bash working-directory: ${{github.workspace}} run: | export PYTHONPATH=$PWD:$PYTHONPATH echo $PYTHONPATH cd egs/yesno/ASR python3 ./tdnn/export_onnx.py --epoch 14 --avg 2 echo "Test float32 model" python3 ./tdnn/onnx_pretrained.py \ --nn-model ./tdnn/exp/model-epoch-14-avg-2.onnx \ --HLG ./data/lang_phone/HLG.pt \ --words-file ./data/lang_phone/words.txt \ download/waves_yesno/0_0_0_1_0_0_0_1.wav \ download/waves_yesno/0_0_1_0_0_0_1_0.wav echo "Test int8 model" python3 ./tdnn/onnx_pretrained.py \ --nn-model ./tdnn/exp/model-epoch-14-avg-2.int8.onnx \ --HLG ./data/lang_phone/HLG.pt \ --words-file ./data/lang_phone/words.txt \ download/waves_yesno/0_0_0_1_0_0_0_1.wav \ download/waves_yesno/0_0_1_0_0_0_1_0.wav - name: Test decoding with H shell: bash working-directory: ${{github.workspace}} run: | export PYTHONPATH=$PWD:$PYTHONPATH echo $PYTHONPATH cd egs/yesno/ASR python3 ./tdnn/export.py --epoch 14 --avg 2 --jit 1 python3 ./tdnn/jit_pretrained_decode_with_H.py \ --nn-model ./tdnn/exp/cpu_jit.pt \ --H ./data/lang_phone/H.fst \ --tokens ./data/lang_phone/tokens.txt \ ./download/waves_yesno/0_0_0_1_0_0_0_1.wav \ ./download/waves_yesno/0_0_1_0_0_0_1_0.wav \ ./download/waves_yesno/0_0_1_0_0_1_1_1.wav - name: Test decoding with HL shell: bash working-directory: ${{github.workspace}} run: | export PYTHONPATH=$PWD:$PYTHONPATH echo $PYTHONPATH cd egs/yesno/ASR python3 ./tdnn/export.py --epoch 14 --avg 2 --jit 1 python3 ./tdnn/jit_pretrained_decode_with_HL.py \ --nn-model ./tdnn/exp/cpu_jit.pt \ --HL ./data/lang_phone/HL.fst \ --words ./data/lang_phone/words.txt \ ./download/waves_yesno/0_0_0_1_0_0_0_1.wav \ ./download/waves_yesno/0_0_1_0_0_0_1_0.wav \ ./download/waves_yesno/0_0_1_0_0_1_1_1.wav - name: Show generated files shell: bash working-directory: ${{github.workspace}} run: | cd egs/yesno/ASR ls -lh tdnn/exp ls -lh data/lang_phone