From 88f45ff121924e1d90be8774cfa5fc84cf3a9786 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Sun, 6 Oct 2024 15:59:07 +0800 Subject: [PATCH] Fix ci --- .github/workflows/speaker-diarization.yaml | 26 +++++++++++++++++++ .gitignore | 1 + .../segmentation/speaker-diarization-onnx.py | 5 ++++ .../segmentation/speaker-diarization-torch.py | 6 +++++ sherpa-onnx/csrc/fast-clustering.cc | 2 +- 5 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/speaker-diarization.yaml b/.github/workflows/speaker-diarization.yaml index c543c1905..0bd6a575c 100644 --- a/.github/workflows/speaker-diarization.yaml +++ b/.github/workflows/speaker-diarization.yaml @@ -25,6 +25,11 @@ jobs: with: fetch-depth: 0 + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: ${{ matrix.os }}-speaker-diarization + - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: @@ -35,11 +40,30 @@ jobs: run: | pip install pyannote.audio onnx onnxruntime + - name: Install sherpa-onnx from source + shell: bash + run: | + python3 -m pip install --upgrade pip + python3 -m pip install wheel twine setuptools + + export CMAKE_CXX_COMPILER_LAUNCHER=ccache + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" + + cat sherpa-onnx/python/sherpa_onnx/__init__.py + + python3 setup.py bdist_wheel + ls -lh dist + pip install ./dist/*.whl + - name: Run tests shell: bash run: | pushd scripts/pyannote/segmentation + python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)" + python3 -c "import sherpa_onnx; print(sherpa_onnx.__version__)" + python3 -c "import sherpa_onnx; print(dir(sherpa_onnx))" + curl -SL -O https://huggingface.co/csukuangfj/pyannote-models/resolve/main/segmentation-3.0/pytorch_model.bin test_wavs=( @@ -53,6 +77,8 @@ jobs: curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-segmentation-models/$w done + soxi *.wav + curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/speaker-segmentation-models/sherpa-onnx-pyannote-segmentation-3-0.tar.bz2 tar xvf sherpa-onnx-pyannote-segmentation-3-0.tar.bz2 rm sherpa-onnx-pyannote-segmentation-3-0.tar.bz2 diff --git a/.gitignore b/.gitignore index 57286c661..b0fbfae78 100644 --- a/.gitignore +++ b/.gitignore @@ -119,3 +119,4 @@ vits-melo-tts-zh_en *.ppu sherpa-onnx-online-punct-en-2024-08-06 *.mp4 +*.mp3 diff --git a/scripts/pyannote/segmentation/speaker-diarization-onnx.py b/scripts/pyannote/segmentation/speaker-diarization-onnx.py index 599ad5859..dd0afc3c8 100755 --- a/scripts/pyannote/segmentation/speaker-diarization-onnx.py +++ b/scripts/pyannote/segmentation/speaker-diarization-onnx.py @@ -1,6 +1,11 @@ #!/usr/bin/env python3 # Copyright 2024 Xiaomi Corp. (authors: Fangjun Kuang) +""" +Please refer to +https://github.com/k2-fsa/sherpa-onnx/blob/master/.github/workflows/speaker-diarization.yaml +for usages. +""" import argparse from datetime import timedelta diff --git a/scripts/pyannote/segmentation/speaker-diarization-torch.py b/scripts/pyannote/segmentation/speaker-diarization-torch.py index 42847eb1f..18a50ec08 100755 --- a/scripts/pyannote/segmentation/speaker-diarization-torch.py +++ b/scripts/pyannote/segmentation/speaker-diarization-torch.py @@ -1,5 +1,11 @@ #!/usr/bin/env python3 +""" +Please refer to +https://github.com/k2-fsa/sherpa-onnx/blob/master/.github/workflows/speaker-diarization.yaml +for usages. +""" + """ 1. Go to https://huggingface.co/hbredin/wespeaker-voxceleb-resnet34-LM/tree/main wget https://huggingface.co/hbredin/wespeaker-voxceleb-resnet34-LM/resolve/main/speaker-embedding.onnx diff --git a/sherpa-onnx/csrc/fast-clustering.cc b/sherpa-onnx/csrc/fast-clustering.cc index f479a707e..f6ac56a36 100644 --- a/sherpa-onnx/csrc/fast-clustering.cc +++ b/sherpa-onnx/csrc/fast-clustering.cc @@ -52,7 +52,7 @@ class FastClustering::Impl { std::vector height(num_rows - 1); fastclustercpp::hclust_fast(num_rows, distance.data(), - fastclustercpp::HCLUST_METHOD_SINGLE, + fastclustercpp::HCLUST_METHOD_COMPLETE, merge.data(), height.data()); std::vector labels(num_rows);