From a3c89aa0d8470d8eab30d7781b3dd7b9ed448046 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 31 Oct 2024 17:54:16 +0800 Subject: [PATCH] Add two-pass ASR Android APKs for Moonshine models. (#1499) --- .github/workflows/apk-asr-2pass.yaml | 4 +-- scripts/apk/generate-asr-2pass-apk-script.py | 38 ++++++++++++++++++++ scripts/apk/generate-vad-asr-apk-script.py | 15 ++++++++ sherpa-onnx/kotlin-api/OfflineRecognizer.kt | 13 +++++++ 4 files changed, 68 insertions(+), 2 deletions(-) diff --git a/.github/workflows/apk-asr-2pass.yaml b/.github/workflows/apk-asr-2pass.yaml index bfbc2f170..72885db45 100644 --- a/.github/workflows/apk-asr-2pass.yaml +++ b/.github/workflows/apk-asr-2pass.yaml @@ -23,8 +23,8 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - total: ["2"] - index: ["0", "1"] + total: ["4"] + index: ["0", "1", "2", "3"] steps: - uses: actions/checkout@v4 diff --git a/scripts/apk/generate-asr-2pass-apk-script.py b/scripts/apk/generate-asr-2pass-apk-script.py index e35a34fb1..87cb0a0b3 100755 --- a/scripts/apk/generate-asr-2pass-apk-script.py +++ b/scripts/apk/generate-asr-2pass-apk-script.py @@ -127,6 +127,36 @@ def get_2nd_models(): ls -lh + popd + """, + ), + Model( + model_name="sherpa-onnx-moonshine-tiny-en-int8", + idx=21, + lang="en", + short_name="moonshine_tiny_int8", + cmd=""" + pushd $model_name + + rm -rfv test_wavs + + ls -lh + + popd + """, + ), + Model( + model_name="sherpa-onnx-moonshine-base-en-int8", + idx=22, + lang="en", + short_name="moonshine_base_int8", + cmd=""" + pushd $model_name + + rm -rfv test_wavs + + ls -lh + popd """, ), @@ -300,6 +330,14 @@ def get_models(): "sherpa-onnx-streaming-zipformer-en-20M-2023-02-17", "sherpa-onnx-whisper-tiny.en", ), + ( + "sherpa-onnx-streaming-zipformer-en-20M-2023-02-17", + "sherpa-onnx-moonshine-tiny-en-int8", + ), + ( + "sherpa-onnx-streaming-zipformer-en-20M-2023-02-17", + "sherpa-onnx-moonshine-base-en-int8", + ), ( "sherpa-onnx-streaming-zipformer-en-20M-2023-02-17", "sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17", diff --git a/scripts/apk/generate-vad-asr-apk-script.py b/scripts/apk/generate-vad-asr-apk-script.py index 5c3694d69..a111ff610 100755 --- a/scripts/apk/generate-vad-asr-apk-script.py +++ b/scripts/apk/generate-vad-asr-apk-script.py @@ -384,6 +384,21 @@ def get_models(): ls -lh + popd + """, + ), + Model( + model_name="sherpa-onnx-moonshine-base-en-int8", + idx=22, + lang="en", + short_name="moonshine_base_int8", + cmd=""" + pushd $model_name + + rm -rfv test_wavs + + ls -lh + popd """, ), diff --git a/sherpa-onnx/kotlin-api/OfflineRecognizer.kt b/sherpa-onnx/kotlin-api/OfflineRecognizer.kt index 76dc82149..647f2447c 100644 --- a/sherpa-onnx/kotlin-api/OfflineRecognizer.kt +++ b/sherpa-onnx/kotlin-api/OfflineRecognizer.kt @@ -438,6 +438,19 @@ fun getOfflineModelConfig(type: Int): OfflineModelConfig? { tokens = "$modelDir/tokens.txt", ) } + + 22 -> { + val modelDir = "sherpa-onnx-moonshine-base-en-int8" + return OfflineModelConfig( + moonshine = OfflineMoonshineModelConfig( + preprocessor = "$modelDir/preprocess.onnx", + encoder = "$modelDir/encode.int8.onnx", + uncachedDecoder = "$modelDir/uncached_decode.int8.onnx", + cachedDecoder = "$modelDir/cached_decode.int8.onnx", + ), + tokens = "$modelDir/tokens.txt", + ) + } } return null }