From 6927c534f5b773875cbb861df33b2c4dec6bee46 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Tue, 9 Apr 2024 13:37:32 +0800 Subject: [PATCH] add CI for audioset --- .github/scripts/audioset/AT/run.sh | 34 ++++++++++++++ .github/workflows/audioset.yml | 74 ++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100755 .github/scripts/audioset/AT/run.sh create mode 100644 .github/workflows/audioset.yml diff --git a/.github/scripts/audioset/AT/run.sh b/.github/scripts/audioset/AT/run.sh new file mode 100755 index 000000000..ee3e102f4 --- /dev/null +++ b/.github/scripts/audioset/AT/run.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +set -ex + +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/audioset/AT + +function test_pretrained() { + repo_url=https://huggingface.co/marcoyang/icefall-audio-tagging-audioset-zipformer-2024-03-12 + repo=$(basename $repo_url) + GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url + pushd $repo/exp + git lfs pull --include pretrained.pt + + ls -lh + + log "test pretrained.pt" + + for w in 1.wav 2.wav 3.wav; do + log "test $w" + python3 zipformer/pretrained.py \ + --checkpoint $repo/exp/pretrained.pt \ + --label-dict $repo/data/class_labels_indices.csv \ + $repo/test_wavs/$w + done + +} + +test_pretrained diff --git a/.github/workflows/audioset.yml b/.github/workflows/audioset.yml new file mode 100644 index 000000000..0d55238e5 --- /dev/null +++ b/.github/workflows/audioset.yml @@ -0,0 +1,74 @@ +name: audioset + +on: + push: + branches: + - master + - audioset-ci + + pull_request: + branches: + - master + + workflow_dispatch: + +concurrency: + group: audioset-${{ github.ref }} + cancel-in-progress: true + +jobs: + generate_build_matrix: + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' + # see https://github.com/pytorch/pytorch/pull/50633 + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Generating build matrix + id: set-matrix + run: | + # outputting for debugging purposes + python ./.github/scripts/docker/generate_build_matrix.py + MATRIX=$(python ./.github/scripts/docker/generate_build_matrix.py) + echo "::set-output name=matrix::${MATRIX}" + + audioset: + needs: generate_build_matrix + name: py${{ matrix.python-version }} torch${{ matrix.torch-version }} v${{ matrix.version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ${{ fromJson(needs.generate_build_matrix.outputs.matrix) }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Free space + shell: bash + run: | + ls -lh + df -h + rm -rf /opt/hostedtoolcache + df -h + echo "pwd: $PWD" + echo "github.workspace ${{ github.workspace }}" + + - name: Run tests + uses: addnab/docker-run-action@v3 + with: + image: ghcr.io/${{ github.repository_owner }}/icefall:cpu-py${{ matrix.python-version }}-torch${{ matrix.torch-version }}-v${{ matrix.version }} + options: | + --volume ${{ github.workspace }}/:/icefall + shell: bash + run: | + export PYTHONPATH=/icefall:$PYTHONPATH + cd /icefall + git config --global --add safe.directory /icefall + + .github/scripts/audioset/AT/run.sh