Skip to content

Commit

Permalink
refactor test-dot-net
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Jun 17, 2024
1 parent 104f029 commit 204b458
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 105 deletions.
71 changes: 35 additions & 36 deletions .github/scripts/test-dart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,41 @@ set -ex

cd dart-api-examples

pushd non-streaming-asr

echo '----------paraformer itn----------'
./run-paraformer-itn.sh

echo '----------paraformer----------'
./run-paraformer.sh
rm -rf sherpa-onnx-*

echo '----------VAD with paraformer----------'
./run-vad-with-paraformer.sh
rm -rf sherpa-onnx-*

echo '----------NeMo transducer----------'
./run-nemo-transducer.sh
rm -rf sherpa-onnx-*

echo '----------NeMo CTC----------'
./run-nemo-ctc.sh
rm -rf sherpa-onnx-*

echo '----------TeleSpeech CTC----------'
./run-telespeech-ctc.sh
rm -rf sherpa-onnx-*

echo '----------whisper----------'
./run-whisper.sh
rm -rf sherpa-onnx-*

echo '----------zipformer transducer----------'
./run-zipformer-transducer.sh
rm -rf sherpa-onnx-*

popd # non-streaming-asr

pushd tts

echo '----------piper tts----------'
Expand Down Expand Up @@ -44,42 +79,6 @@ rm -rf sherpa-onnx-*

popd # streaming-asr

pushd non-streaming-asr

echo '----------VAD with paraformer----------'
./run-vad-with-paraformer.sh
rm -rf sherpa-onnx-*

echo '----------NeMo transducer----------'
./run-nemo-transducer.sh
rm -rf sherpa-onnx-*

echo '----------NeMo CTC----------'
./run-nemo-ctc.sh
rm -rf sherpa-onnx-*

echo '----------TeleSpeech CTC----------'
./run-telespeech-ctc.sh
rm -rf sherpa-onnx-*

echo '----------paraformer itn----------'
./run-paraformer-itn.sh
rm -rf sherpa-onnx-*

echo '----------paraformer----------'
./run-paraformer.sh
rm -rf sherpa-onnx-*

echo '----------whisper----------'
./run-whisper.sh
rm -rf sherpa-onnx-*

echo '----------zipformer transducer----------'
./run-zipformer-transducer.sh
rm -rf sherpa-onnx-*

popd # non-streaming-asr

pushd vad
./run.sh
rm *.onnx
Expand Down
68 changes: 2 additions & 66 deletions .github/workflows/test-dot-net.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest]
python-version: ["3.8"]

steps:
Expand All @@ -62,7 +62,6 @@ jobs:
mkdir build
cd build
cmake \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64' \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_BUILD_TYPE=Release \
Expand All @@ -73,45 +72,18 @@ jobs:
cmake --build . --target install --config Release
- name: Build sherpa-onnx for windows x86
if: matrix.os == 'windows-latest'
shell: bash
run: |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
cmake --version
mkdir build-win32
cd build-win32
cmake \
-A Win32 \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=./install \
-DCMAKE_BUILD_TYPE=Release \
-DSHERPA_ONNX_ENABLE_WEBSOCKET=OFF \
-DBUILD_ESPEAK_NG_EXE=OFF \
-DSHERPA_ONNX_ENABLE_BINARY=ON \
..
cmake --build . --target install --config Release
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}
path: ./build/install/lib/

- uses: actions/upload-artifact@v4
if: matrix.os == 'windows-latest'
with:
name: ${{ matrix.os }}-win32
path: ./build-win32/install/lib/

test-dot-net:
runs-on: ${{ matrix.os }}
needs: [build-libs]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest] #, windows-latest]
os: [ubuntu-latest]
python-version: ["3.8"]

steps:
Expand All @@ -135,30 +107,6 @@ jobs:
name: ubuntu-latest
path: /tmp/linux

- name: Retrieve artifact from macos-latest (x64)
uses: actions/download-artifact@v4
with:
name: macos-latest
path: /tmp/macos-x64

- name: Retrieve artifact from macos-latest (arm64)
uses: actions/download-artifact@v4
with:
name: macos-latest
path: /tmp/macos-arm64

- name: Retrieve artifact from windows-latest
uses: actions/download-artifact@v4
with:
name: windows-latest
path: /tmp/windows-x64

- name: Retrieve artifact from windows-latest
uses: actions/download-artifact@v4
with:
name: windows-latest-win32
path: /tmp/windows-x86

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
Expand All @@ -177,18 +125,6 @@ jobs:
echo "----------/tmp/linux----------"
ls -lh /tmp/linux
echo "----------/tmp/macos-x64----------"
ls -lh /tmp/macos-x64
echo "----------/tmp/macos-arm64----------"
ls -lh /tmp/macos-arm64
echo "----------/tmp/windows-x64----------"
ls -lh /tmp/windows-x64
echo "----------/tmp/windows-x86----------"
ls -lh /tmp/windows-x86
- name: Build
shell: bash
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void main(List<String> arguments) async {

final model = res['model'] as String;
final tokens = res['tokens'] as String;
final ruleFsts = res['rule-fst'] as String;
final ruleFsts = res['rule-fsts'] as String;
final inputWav = res['input-wav'] as String;

final paraformer = sherpa_onnx.OfflineParaformerModelConfig(
Expand Down
2 changes: 1 addition & 1 deletion dotnet-examples/offline-decode-files/run-telespeech-ctc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ fi
dotnet run \
--telespeech-ctc=./sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04/model.int8.onnx \
--tokens=./sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04/tokens.txt \
--model-type=telespeech-ctc \
--model-type=telespeech_ctc \
--files ./sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04/test_wavs/3-sichuan.wav
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ go build
./non-streaming-decode-files \
--telespeech-ctc ./sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04/model.int8.onnx \
--tokens ./sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04/tokens.txt \
--model-type telespeech-ctc \
--model-type telespeech_ctc \
--debug 0 \
./sherpa-onnx-telespeech-ctc-int8-zh-2024-06-04/test_wavs/3-sichuan.wav
5 changes: 5 additions & 0 deletions sherpa-onnx/flutter/lib/src/offline_recognizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,13 @@ class OfflineRecognizer {
c.ref.hotwordsFile = config.hotwordsFile.toNativeUtf8();
c.ref.hotwordsScore = config.hotwordsScore;

c.ref.ruleFsts = config.ruleFsts.toNativeUtf8();
c.ref.ruleFars = config.ruleFars.toNativeUtf8();

final ptr = SherpaOnnxBindings.createOfflineRecognizer?.call(c) ?? nullptr;

calloc.free(c.ref.ruleFars);
calloc.free(c.ref.ruleFsts);
calloc.free(c.ref.hotwordsFile);
calloc.free(c.ref.decodingMethod);
calloc.free(c.ref.lm.model);
Expand Down

0 comments on commit 204b458

Please sign in to comment.