Add links to pre-built APKs and pre-trained models to README. (#840)
This commit is contained in:
174
.github/workflows/apk-asr-2pass.yaml
vendored
Normal file
174
.github/workflows/apk-asr-2pass.yaml
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
name: apk-asr-2pass
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: apk-asr-2pass-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
apk_asr_2pass:
|
||||
if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa'
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: apk for asr ${{ matrix.index }}/${{ matrix.total }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
total: ["2"]
|
||||
index: ["0", "1"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# https://github.com/actions/setup-java
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin' # See 'Supported distributions' for available options
|
||||
java-version: '21'
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-android
|
||||
|
||||
- name: Display NDK HOME
|
||||
shell: bash
|
||||
run: |
|
||||
echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}"
|
||||
ls -lh ${ANDROID_NDK_LATEST_HOME}
|
||||
|
||||
- name: Install Python dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip jinja2
|
||||
|
||||
- name: Setup build tool version variable
|
||||
shell: bash
|
||||
run: |
|
||||
echo "---"
|
||||
ls -lh /usr/local/lib/android/
|
||||
echo "---"
|
||||
|
||||
ls -lh /usr/local/lib/android/sdk
|
||||
echo "---"
|
||||
|
||||
ls -lh /usr/local/lib/android/sdk/build-tools
|
||||
echo "---"
|
||||
|
||||
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
|
||||
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
|
||||
echo "Last build tool version is: $BUILD_TOOL_VERSION"
|
||||
|
||||
- name: Generate build script
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts/apk
|
||||
|
||||
total=${{ matrix.total }}
|
||||
index=${{ matrix.index }}
|
||||
|
||||
./generate-asr-2pass-apk-script.py --total $total --index $index
|
||||
|
||||
chmod +x build-apk-asr-2pass.sh
|
||||
mv -v ./build-apk-asr-2pass.sh ../..
|
||||
|
||||
- name: build APK
|
||||
shell: bash
|
||||
run: |
|
||||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
cmake --version
|
||||
|
||||
export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME
|
||||
./build-apk-asr-2pass.sh
|
||||
|
||||
- name: Display APK
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
# https://github.com/marketplace/actions/sign-android-release
|
||||
- uses: r0adkll/sign-android-release@v1
|
||||
name: Sign app APK
|
||||
with:
|
||||
releaseDirectory: ./apks
|
||||
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }}
|
||||
alias: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
|
||||
keyStorePassword: ${{ secrets.ANDROID_SIGNING_KEY_STORE_PASSWORD }}
|
||||
env:
|
||||
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
|
||||
|
||||
- name: Display APK after signing
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
- name: Rename APK after signing
|
||||
shell: bash
|
||||
run: |
|
||||
cd apks
|
||||
rm -fv signingKey.jks
|
||||
rm -fv *.apk.idsig
|
||||
rm -fv *-aligned.apk
|
||||
|
||||
all_apks=$(ls -1 *-signed.apk)
|
||||
echo "----"
|
||||
echo $all_apks
|
||||
echo "----"
|
||||
for apk in ${all_apks[@]}; do
|
||||
n=$(echo $apk | sed -e s/-signed//)
|
||||
mv -v $apk $n
|
||||
done
|
||||
|
||||
cd ..
|
||||
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
- name: Display APK after rename
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
- name: Publish to huggingface
|
||||
env:
|
||||
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
||||
uses: nick-fields/retry@v3
|
||||
with:
|
||||
max_attempts: 20
|
||||
timeout_seconds: 200
|
||||
shell: bash
|
||||
command: |
|
||||
git config --global user.email "csukuangfj@gmail.com"
|
||||
git config --global user.name "Fangjun Kuang"
|
||||
|
||||
rm -rf huggingface
|
||||
export GIT_LFS_SKIP_SMUDGE=1
|
||||
|
||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||
cd huggingface
|
||||
git fetch
|
||||
git pull
|
||||
git merge -m "merge remote" --ff origin main
|
||||
|
||||
mkdir -p asr-2pass
|
||||
cp -v ../apks/*.apk ./asr-2pass/
|
||||
git status
|
||||
git lfs track "*.apk"
|
||||
git add .
|
||||
git commit -m "add more apks"
|
||||
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk main
|
||||
4
.github/workflows/apk-asr.yaml
vendored
4
.github/workflows/apk-asr.yaml
vendored
@@ -23,8 +23,8 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
total: ["1"]
|
||||
index: ["0"]
|
||||
total: ["3"]
|
||||
index: ["0", "1", "2"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
23
.github/workflows/apk-kws.yaml
vendored
23
.github/workflows/apk-kws.yaml
vendored
@@ -16,11 +16,15 @@ permissions:
|
||||
|
||||
jobs:
|
||||
apk_kws:
|
||||
if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa'
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: apk for kws ${{ matrix.index }}/${{ matrix.total }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
total: ["1"]
|
||||
index: ["0"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -44,6 +48,11 @@ jobs:
|
||||
echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}"
|
||||
ls -lh ${ANDROID_NDK_LATEST_HOME}
|
||||
|
||||
- name: Install Python dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip jinja2
|
||||
|
||||
- name: Setup build tool version variable
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -61,6 +70,16 @@ jobs:
|
||||
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
|
||||
echo "Last build tool version is: $BUILD_TOOL_VERSION"
|
||||
|
||||
- name: Generate build script
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts/apk
|
||||
|
||||
total=${{ matrix.total }}
|
||||
index=${{ matrix.index }}
|
||||
|
||||
mv -v ./build-apk-kws.sh ../..
|
||||
|
||||
- name: build APK
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -69,13 +88,13 @@ jobs:
|
||||
cmake --version
|
||||
|
||||
export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME
|
||||
./build-kws-apk.sh
|
||||
./build-apk-kws.sh
|
||||
|
||||
- name: Display APK
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
|
||||
du -h -d1 .
|
||||
|
||||
# https://github.com/marketplace/actions/sign-android-release
|
||||
- uses: r0adkll/sign-android-release@v1
|
||||
|
||||
174
.github/workflows/apk-vad-asr.yaml
vendored
Normal file
174
.github/workflows/apk-vad-asr.yaml
vendored
Normal file
@@ -0,0 +1,174 @@
|
||||
name: apk-vad-asr
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: apk-vad-asr-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
apk_vad_asr:
|
||||
if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa'
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: apk for asr ${{ matrix.index }}/${{ matrix.total }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
total: ["3"]
|
||||
index: ["0", "1", "2"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# https://github.com/actions/setup-java
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin' # See 'Supported distributions' for available options
|
||||
java-version: '21'
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-android
|
||||
|
||||
- name: Display NDK HOME
|
||||
shell: bash
|
||||
run: |
|
||||
echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}"
|
||||
ls -lh ${ANDROID_NDK_LATEST_HOME}
|
||||
|
||||
- name: Install Python dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip jinja2
|
||||
|
||||
- name: Setup build tool version variable
|
||||
shell: bash
|
||||
run: |
|
||||
echo "---"
|
||||
ls -lh /usr/local/lib/android/
|
||||
echo "---"
|
||||
|
||||
ls -lh /usr/local/lib/android/sdk
|
||||
echo "---"
|
||||
|
||||
ls -lh /usr/local/lib/android/sdk/build-tools
|
||||
echo "---"
|
||||
|
||||
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
|
||||
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
|
||||
echo "Last build tool version is: $BUILD_TOOL_VERSION"
|
||||
|
||||
- name: Generate build script
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts/apk
|
||||
|
||||
total=${{ matrix.total }}
|
||||
index=${{ matrix.index }}
|
||||
|
||||
./generate-vad-asr-apk-script.py --total $total --index $index
|
||||
|
||||
chmod +x build-apk-vad-asr.sh
|
||||
mv -v ./build-apk-vad-asr.sh ../..
|
||||
|
||||
- name: build APK
|
||||
shell: bash
|
||||
run: |
|
||||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
cmake --version
|
||||
|
||||
export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME
|
||||
./build-apk-vad-asr.sh
|
||||
|
||||
- name: Display APK
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
# https://github.com/marketplace/actions/sign-android-release
|
||||
- uses: r0adkll/sign-android-release@v1
|
||||
name: Sign app APK
|
||||
with:
|
||||
releaseDirectory: ./apks
|
||||
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }}
|
||||
alias: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
|
||||
keyStorePassword: ${{ secrets.ANDROID_SIGNING_KEY_STORE_PASSWORD }}
|
||||
env:
|
||||
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
|
||||
|
||||
- name: Display APK after signing
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
- name: Rename APK after signing
|
||||
shell: bash
|
||||
run: |
|
||||
cd apks
|
||||
rm -fv signingKey.jks
|
||||
rm -fv *.apk.idsig
|
||||
rm -fv *-aligned.apk
|
||||
|
||||
all_apks=$(ls -1 *-signed.apk)
|
||||
echo "----"
|
||||
echo $all_apks
|
||||
echo "----"
|
||||
for apk in ${all_apks[@]}; do
|
||||
n=$(echo $apk | sed -e s/-signed//)
|
||||
mv -v $apk $n
|
||||
done
|
||||
|
||||
cd ..
|
||||
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
- name: Display APK after rename
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
- name: Publish to huggingface
|
||||
env:
|
||||
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
||||
uses: nick-fields/retry@v3
|
||||
with:
|
||||
max_attempts: 20
|
||||
timeout_seconds: 200
|
||||
shell: bash
|
||||
command: |
|
||||
git config --global user.email "csukuangfj@gmail.com"
|
||||
git config --global user.name "Fangjun Kuang"
|
||||
|
||||
rm -rf huggingface
|
||||
export GIT_LFS_SKIP_SMUDGE=1
|
||||
|
||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||
cd huggingface
|
||||
git fetch
|
||||
git pull
|
||||
git merge -m "merge remote" --ff origin main
|
||||
|
||||
mkdir -p vad-asr
|
||||
cp -v ../apks/*.apk ./vad-asr/
|
||||
git status
|
||||
git lfs track "*.apk"
|
||||
git add .
|
||||
git commit -m "add more apks"
|
||||
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk main
|
||||
171
.github/workflows/apk-vad.yaml
vendored
Normal file
171
.github/workflows/apk-vad.yaml
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
name: apk-vad
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: apk-vad-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
apk_vad:
|
||||
if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa'
|
||||
runs-on: ${{ matrix.os }}
|
||||
name: apk for vad ${{ matrix.index }}/${{ matrix.total }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
total: ["1"]
|
||||
index: ["0"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# https://github.com/actions/setup-java
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin' # See 'Supported distributions' for available options
|
||||
java-version: '21'
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-android
|
||||
|
||||
- name: Display NDK HOME
|
||||
shell: bash
|
||||
run: |
|
||||
echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}"
|
||||
ls -lh ${ANDROID_NDK_LATEST_HOME}
|
||||
|
||||
- name: Install Python dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
python3 -m pip install --upgrade pip jinja2
|
||||
|
||||
- name: Setup build tool version variable
|
||||
shell: bash
|
||||
run: |
|
||||
echo "---"
|
||||
ls -lh /usr/local/lib/android/
|
||||
echo "---"
|
||||
|
||||
ls -lh /usr/local/lib/android/sdk
|
||||
echo "---"
|
||||
|
||||
ls -lh /usr/local/lib/android/sdk/build-tools
|
||||
echo "---"
|
||||
|
||||
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1)
|
||||
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV
|
||||
echo "Last build tool version is: $BUILD_TOOL_VERSION"
|
||||
|
||||
- name: Generate build script
|
||||
shell: bash
|
||||
run: |
|
||||
cd scripts/apk
|
||||
|
||||
total=${{ matrix.total }}
|
||||
index=${{ matrix.index }}
|
||||
|
||||
mv -v ./build-apk-vad.sh ../..
|
||||
|
||||
- name: build APK
|
||||
shell: bash
|
||||
run: |
|
||||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
cmake --version
|
||||
|
||||
export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME
|
||||
./build-apk-vad.sh
|
||||
|
||||
- name: Display APK
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
# https://github.com/marketplace/actions/sign-android-release
|
||||
- uses: r0adkll/sign-android-release@v1
|
||||
name: Sign app APK
|
||||
with:
|
||||
releaseDirectory: ./apks
|
||||
signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }}
|
||||
alias: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }}
|
||||
keyStorePassword: ${{ secrets.ANDROID_SIGNING_KEY_STORE_PASSWORD }}
|
||||
env:
|
||||
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }}
|
||||
|
||||
- name: Display APK after signing
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
- name: Rename APK after signing
|
||||
shell: bash
|
||||
run: |
|
||||
cd apks
|
||||
rm -fv signingKey.jks
|
||||
rm -fv *.apk.idsig
|
||||
rm -fv *-aligned.apk
|
||||
|
||||
all_apks=$(ls -1 *-signed.apk)
|
||||
echo "----"
|
||||
echo $all_apks
|
||||
echo "----"
|
||||
for apk in ${all_apks[@]}; do
|
||||
n=$(echo $apk | sed -e s/-signed//)
|
||||
mv -v $apk $n
|
||||
done
|
||||
|
||||
cd ..
|
||||
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
- name: Display APK after rename
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
du -h -d1 .
|
||||
|
||||
- name: Publish to huggingface
|
||||
env:
|
||||
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
||||
uses: nick-fields/retry@v3
|
||||
with:
|
||||
max_attempts: 20
|
||||
timeout_seconds: 200
|
||||
shell: bash
|
||||
command: |
|
||||
git config --global user.email "csukuangfj@gmail.com"
|
||||
git config --global user.name "Fangjun Kuang"
|
||||
|
||||
rm -rf huggingface
|
||||
export GIT_LFS_SKIP_SMUDGE=1
|
||||
|
||||
git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface
|
||||
cd huggingface
|
||||
git fetch
|
||||
git pull
|
||||
git merge -m "merge remote" --ff origin main
|
||||
|
||||
mkdir -p vad
|
||||
cp -v ../apks/*.apk ./vad/
|
||||
git status
|
||||
git lfs track "*.apk"
|
||||
git add .
|
||||
git commit -m "add more apks"
|
||||
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk main
|
||||
73
.github/workflows/apk.yaml
vendored
73
.github/workflows/apk.yaml
vendored
@@ -1,73 +0,0 @@
|
||||
name: apk
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: apk-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
apk:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# https://github.com/actions/setup-java
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin' # See 'Supported distributions' for available options
|
||||
java-version: '21'
|
||||
|
||||
- name: ccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2
|
||||
with:
|
||||
key: ${{ matrix.os }}-android
|
||||
|
||||
- name: Display NDK HOME
|
||||
shell: bash
|
||||
run: |
|
||||
echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}"
|
||||
ls -lh ${ANDROID_NDK_LATEST_HOME}
|
||||
|
||||
- name: build APK
|
||||
shell: bash
|
||||
run: |
|
||||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache
|
||||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH"
|
||||
cmake --version
|
||||
|
||||
export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME
|
||||
./build-apk-vad.sh
|
||||
./build-apk-two-pass.sh
|
||||
./build-apk.sh
|
||||
|
||||
- name: Display APK
|
||||
shell: bash
|
||||
run: |
|
||||
ls -lh ./apks/
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
path: ./apks/*.apk
|
||||
|
||||
- name: Release APK
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
file_glob: true
|
||||
file: apks/*.apk
|
||||
overwrite: true
|
||||
2
.github/workflows/test-nodejs-addon-api.yaml
vendored
2
.github/workflows/test-nodejs-addon-api.yaml
vendored
@@ -39,7 +39,7 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04, windows-latest]
|
||||
os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04] #, windows-latest]
|
||||
node-version: ["16", "17", "18", "19", "21", "22"]
|
||||
python-version: ["3.8"]
|
||||
|
||||
|
||||
31
README.md
31
README.md
@@ -37,12 +37,37 @@ with the following APIs
|
||||
- Kotlin
|
||||
- Swift
|
||||
|
||||
# Links for pre-built Android APKs
|
||||
|
||||
| Description | URL | 中国用户 |
|
||||
|--------------------------------|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|
|
||||
| Streaming speech recognition | [Address](https://k2-fsa.github.io/sherpa/onnx/android/apk.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/android/apk-cn.html) |
|
||||
| Text-to-speech | [Address](https://k2-fsa.github.io/sherpa/onnx/tts/apk-engine.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/tts/apk-engine-cn.html) |
|
||||
|Voice activity detection (VAD) | [Address](https://k2-fsa.github.io/sherpa/onnx/vad/apk.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/vad/apk-cn.html)|
|
||||
|VAD + non-streaming speech recognition| [Address](https://k2-fsa.github.io/sherpa/onnx/vad/apk-asr.html)| [点此](https://k2-fsa.github.io/sherpa/onnx/vad/apk-asr-cn.html)|
|
||||
|Two-pass speech recognition| [Address](https://k2-fsa.github.io/sherpa/onnx/android/apk-2pass.html)| [点此](https://k2-fsa.github.io/sherpa/onnx/android/apk-2pass-cn.html)|
|
||||
| Audio tagging | [Address](https://k2-fsa.github.io/sherpa/onnx/audio-tagging/apk.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/audio-tagging/apk-cn.html) |
|
||||
| Audio tagging (WearOS) | [Address](https://k2-fsa.github.io/sherpa/onnx/audio-tagging/apk-wearos.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/audio-tagging/apk-wearos-cn.html) |
|
||||
| Speaker identification | [Address](https://k2-fsa.github.io/sherpa/onnx/speaker-identification/apk.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/speaker-identification/apk-cn.html) |
|
||||
| Spoken language identification | [Address](https://k2-fsa.github.io/sherpa/onnx/spoken-language-identification/apk.html) | [点此](https://k2-fsa.github.io/sherpa/onnx/spoken-language-identification/apk-cn.html) |
|
||||
|Keyword spotting| [Address](https://k2-fsa.github.io/sherpa/onnx/kws/apk.html)| [点此](https://k2-fsa.github.io/sherpa/onnx/kws/apk-cn.html)|
|
||||
|
||||
# Links for pre-trained models
|
||||
|
||||
| Description | URL |
|
||||
|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------|
|
||||
| Speech recognition (speech to text, ASR) | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/asr-models) |
|
||||
| Text-to-speech (TTS) | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models) |
|
||||
| VAD | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx)|
|
||||
| Keyword spotting |[Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/kws-models)|
|
||||
| Audio tagging | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/audio-tagging-models)|
|
||||
| Speaker identification (Speaker ID) | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/speaker-recongition-models)|
|
||||
| Spoken language identification (Language ID) | See multi-lingual Whisper ASR models from [Speech recognition](https://github.com/k2-fsa/sherpa-onnx/releases/tag/asr-models) |
|
||||
| Punctuation| [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/punctuation-models)|
|
||||
|
||||
# Useful links
|
||||
|
||||
- Documentation: https://k2-fsa.github.io/sherpa/onnx/
|
||||
- APK for the text-to-speech engine: https://k2-fsa.github.io/sherpa/onnx/tts/apk-engine.html
|
||||
- APK for speaker identification: https://k2-fsa.github.io/sherpa/onnx/speaker-identification/apk.html
|
||||
- APK for speech recognition: https://github.com/k2-fsa/sherpa-onnx/releases/
|
||||
- Bilibili 演示视频: https://search.bilibili.com/all?keyword=%E6%96%B0%E4%B8%80%E4%BB%A3Kaldi
|
||||
|
||||
# How to reach us
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">VAD</string>
|
||||
<string name="app_name">VAD: Next-gen Kaldi</string>
|
||||
|
||||
<string name="hint">Click the Start button to play Silero VAD with Next-gen Kaldi.</string>
|
||||
<string name="start">Start</string>
|
||||
|
||||
@@ -8,7 +8,6 @@ import android.media.MediaRecorder
|
||||
import android.os.Bundle
|
||||
import android.text.method.ScrollingMovementMethod
|
||||
import android.util.Log
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@@ -200,12 +199,12 @@ class MainActivity : AppCompatActivity() {
|
||||
// Please change getOfflineModelConfig() to add new models
|
||||
// See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html
|
||||
// for a list of available models
|
||||
val secondType = 0
|
||||
Log.i(TAG, "Select model type ${secondType} for the second pass")
|
||||
val asrModelType = 0
|
||||
Log.i(TAG, "Select model type ${asrModelType} for ASR")
|
||||
|
||||
val config = OfflineRecognizerConfig(
|
||||
featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80),
|
||||
modelConfig = getOfflineModelConfig(type = secondType)!!,
|
||||
modelConfig = getOfflineModelConfig(type = asrModelType)!!,
|
||||
)
|
||||
|
||||
offlineRecognizer = OfflineRecognizer(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<resources>
|
||||
<string name="app_name">VAD+ASR</string>
|
||||
<string name="app_name">VAD+ASR: Next-gen Kaldi</string>
|
||||
<string name="hint">Click the Start button to play speech-to-text with Next-gen Kaldi.
|
||||
\n
|
||||
\n\n\n
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Please set the environment variable ANDROID_NDK
|
||||
# before running this script
|
||||
|
||||
# Inside the $ANDROID_NDK directory, you can find a binary ndk-build
|
||||
# and some other files like the file "build/cmake/android.toolchain.cmake"
|
||||
|
||||
set -e
|
||||
|
||||
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]}) $*"
|
||||
}
|
||||
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
|
||||
log "Building two-pass APK for sherpa-onnx v${SHERPA_ONNX_VERSION}"
|
||||
|
||||
log "====================arm64-v8a================="
|
||||
./build-android-arm64-v8a.sh
|
||||
log "====================armv7-eabi================"
|
||||
./build-android-armv7-eabi.sh
|
||||
log "====================x86-64===================="
|
||||
./build-android-x86-64.sh
|
||||
log "====================x86===================="
|
||||
./build-android-x86.sh
|
||||
|
||||
mkdir -p apks
|
||||
|
||||
log "Download 1st pass streaming model (English)"
|
||||
|
||||
# Download the model
|
||||
# see https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#csukuangfj-sherpa-onnx-streaming-zipformer-en-20m-2023-02-17-english
|
||||
repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-en-20M-2023-02-17
|
||||
log "$repo_url"
|
||||
|
||||
log "Start downloading ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "Download pretrained model from $repo_url"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
|
||||
# remove .git to save spaces
|
||||
rm -rf .git
|
||||
rm README.md
|
||||
rm -rf test_wavs
|
||||
rm .gitattributes
|
||||
rm export-onnx*.sh
|
||||
|
||||
rm encoder-epoch-99-avg-1.onnx
|
||||
rm decoder-epoch-99-avg-1.int8.onnx
|
||||
rm joiner-epoch-99-avg-1.onnx
|
||||
|
||||
ls -lh
|
||||
popd
|
||||
|
||||
mv -v $repo ./android/SherpaOnnx2Pass/app/src/main/assets/
|
||||
tree ./android/SherpaOnnx2Pass/app/src/main/assets/
|
||||
repo_1st=$repo
|
||||
|
||||
# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/whisper/tiny.en.html
|
||||
repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-whisper-tiny.en
|
||||
log "$repo_url"
|
||||
|
||||
log "Start downloading ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "Download pretrained model from $repo_url"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
|
||||
# remove .git to save spaces
|
||||
rm -rf .git
|
||||
rm -fv README.md
|
||||
rm -rf test_wavs
|
||||
rm .gitattributes
|
||||
|
||||
rm -fv *.ort
|
||||
rm tiny.en-encoder.onnx
|
||||
rm tiny.en-decoder.onnx
|
||||
|
||||
ls -lh
|
||||
popd
|
||||
|
||||
mv -v $repo ./android/SherpaOnnx2Pass/app/src/main/assets/
|
||||
tree ./android/SherpaOnnx2Pass/app/src/main/assets/
|
||||
repo_2nd=$repo
|
||||
|
||||
pushd android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx
|
||||
# sed -i.bak s/"firstType = 1"/"firstType = 1"/ ./MainActivity.kt
|
||||
sed -i.bak s/"secondType = 1"/"secondType = 2"/ ./MainActivity.kt
|
||||
git diff
|
||||
popd
|
||||
|
||||
for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
log "------------------------------------------------------------"
|
||||
log "build apk for $arch"
|
||||
log "------------------------------------------------------------"
|
||||
src_arch=$arch
|
||||
if [ $arch == "armeabi-v7a" ]; then
|
||||
src_arch=armv7-eabi
|
||||
elif [ $arch == "x86_64" ]; then
|
||||
src_arch=x86-64
|
||||
fi
|
||||
|
||||
ls -lh ./build-android-$src_arch/install/lib/*.so
|
||||
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnx2Pass
|
||||
./gradlew build
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnx2Pass/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-en-2pass-whisper-tiny.en.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
|
||||
git checkout .
|
||||
|
||||
rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$repo_1st
|
||||
rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$repo_2nd
|
||||
|
||||
log "=================================================="
|
||||
log " two-pass Chinese "
|
||||
log "=================================================="
|
||||
|
||||
log "Download 1st pass streaming model (Chinese)"
|
||||
# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#sherpa-onnx-streaming-zipformer-zh-14m-2023-02-23
|
||||
repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23
|
||||
log "$repo_url"
|
||||
|
||||
log "Start downloading ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "Download pretrained model from $repo_url"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
|
||||
# remove .git to save spaces
|
||||
rm -rf .git
|
||||
rm README.md
|
||||
rm -rf test_wavs
|
||||
rm .gitattributes
|
||||
rm export-onnx*.sh
|
||||
|
||||
rm encoder-epoch-99-avg-1.onnx
|
||||
rm decoder-epoch-99-avg-1.int8.onnx
|
||||
rm joiner-epoch-99-avg-1.onnx
|
||||
|
||||
ls -lh
|
||||
popd
|
||||
|
||||
mv -v $repo ./android/SherpaOnnx2Pass/app/src/main/assets/
|
||||
tree ./android/SherpaOnnx2Pass/app/src/main/assets/
|
||||
repo_1st=$repo
|
||||
|
||||
# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/offline-paraformer/paraformer-models.html#csukuangfj-sherpa-onnx-paraformer-zh-2023-03-28-chinese
|
||||
repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-paraformer-zh-2023-03-28
|
||||
log "$repo_url"
|
||||
|
||||
log "Start downloading ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "Download pretrained model from $repo_url"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
|
||||
# remove .git to save spaces
|
||||
rm -rf .git
|
||||
rm README.md
|
||||
rm -rf test_wavs
|
||||
rm .gitattributes
|
||||
|
||||
rm model.onnx
|
||||
|
||||
ls -lh
|
||||
popd
|
||||
|
||||
mv -v $repo ./android/SherpaOnnx2Pass/app/src/main/assets/
|
||||
tree ./android/SherpaOnnx2Pass/app/src/main/assets/
|
||||
repo_2nd=$repo
|
||||
|
||||
pushd android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx
|
||||
sed -i.bak s/"firstType = 1"/"firstType = 0"/ ./MainActivity.kt
|
||||
sed -i.bak s/"secondType = 1"/"secondType = 0"/ ./MainActivity.kt
|
||||
git diff
|
||||
popd
|
||||
|
||||
for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
log "------------------------------------------------------------"
|
||||
log "build apk for $arch"
|
||||
log "------------------------------------------------------------"
|
||||
src_arch=$arch
|
||||
if [ $arch == "armeabi-v7a" ]; then
|
||||
src_arch=armv7-eabi
|
||||
elif [ $arch == "x86_64" ]; then
|
||||
src_arch=x86-64
|
||||
fi
|
||||
|
||||
ls -lh ./build-android-$src_arch/install/lib/*.so
|
||||
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnx2Pass
|
||||
./gradlew build
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnx2Pass/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-zh-2pass-paraformer.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
|
||||
git checkout .
|
||||
|
||||
rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$repo_1st
|
||||
rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$repo_2nd
|
||||
|
||||
ls -lh apks/
|
||||
291
build-apk.sh
291
build-apk.sh
@@ -1,291 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Please set the environment variable ANDROID_NDK
|
||||
# before running this script
|
||||
|
||||
# Inside the $ANDROID_NDK directory, you can find a binary ndk-build
|
||||
# and some other files like the file "build/cmake/android.toolchain.cmake"
|
||||
|
||||
set -e
|
||||
|
||||
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]}) $*"
|
||||
}
|
||||
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
|
||||
log "Building APK for sherpa-onnx v${SHERPA_ONNX_VERSION}"
|
||||
|
||||
log "====================arm64-v8a================="
|
||||
./build-android-arm64-v8a.sh
|
||||
log "====================armv7-eabi================"
|
||||
./build-android-armv7-eabi.sh
|
||||
log "====================x86-64===================="
|
||||
./build-android-x86-64.sh
|
||||
log "====================x86===================="
|
||||
./build-android-x86.sh
|
||||
|
||||
|
||||
mkdir -p apks
|
||||
|
||||
log "https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-en-2023-06-26"
|
||||
|
||||
# Download the model
|
||||
# see https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#csukuangfj-sherpa-onnx-streaming-zipformer-en-2023-06-26-english
|
||||
repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-en-2023-06-26
|
||||
log "Start testing ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "Download pretrained model and test-data from $repo_url"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
|
||||
# remove .git to save spaces
|
||||
rm -rf .git
|
||||
rm README.md
|
||||
rm -v *64*
|
||||
rm -v encoder-epoch-99-avg-1-chunk-16-left-128.onnx
|
||||
rm -v decoder-epoch-99-avg-1-chunk-16-left-128.int8.onnx
|
||||
rm -v joiner-epoch-99-avg-1-chunk-16-left-128.int8.onnx
|
||||
rm -rfv test_wavs
|
||||
rm -v *.sh
|
||||
ls -lh
|
||||
popd
|
||||
|
||||
mv -v $repo ./android/SherpaOnnx/app/src/main/assets/
|
||||
tree ./android/SherpaOnnx/app/src/main/assets/
|
||||
|
||||
pushd android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx
|
||||
sed -i.bak s/"type = 0"/"type = 6"/ ./MainActivity.kt
|
||||
git diff
|
||||
popd
|
||||
|
||||
for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
log "------------------------------------------------------------"
|
||||
log "build apk for $arch"
|
||||
log "------------------------------------------------------------"
|
||||
src_arch=$arch
|
||||
if [ $arch == "armeabi-v7a" ]; then
|
||||
src_arch=armv7-eabi
|
||||
elif [ $arch == "x86_64" ]; then
|
||||
src_arch=x86-64
|
||||
fi
|
||||
|
||||
ls -lh ./build-android-$src_arch/install/lib/*.so
|
||||
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnx
|
||||
./gradlew build
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnx/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-en.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnx/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
|
||||
git checkout .
|
||||
|
||||
rm -rf ./android/SherpaOnnx/app/src/main/assets/$repo
|
||||
|
||||
# type 3, encoder int8, zh
|
||||
log "https://huggingface.co/pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615"
|
||||
# see
|
||||
# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#pkufool-icefall-asr-zipformer-streaming-wenetspeech-20230615-chinese
|
||||
|
||||
# Download the model
|
||||
repo_url=https://huggingface.co/pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615
|
||||
log "Start testing ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "Download pretrained model and test-data from $repo_url"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
|
||||
# remove .git to save spaces
|
||||
rm -rf .git
|
||||
rm README.md
|
||||
rm -rf logs
|
||||
rm -rf scripts
|
||||
rm -rf test_wavs
|
||||
rm -rf data/.DS_Store
|
||||
rm data/lang_char/*.pt
|
||||
rm data/lang_char/lexicon.txt
|
||||
rm data/lang_char/words.txt
|
||||
rm -v exp/*.pt
|
||||
rm -v exp/*32*
|
||||
rm -v exp/*256*
|
||||
rm -v exp/encoder-epoch-12-avg-4-chunk-16-left-128.onnx
|
||||
rm -v exp/decoder-epoch-12-avg-4-chunk-16-left-128.int8.onnx
|
||||
rm -v exp/joiner-epoch-12-avg-4-chunk-16-left-128.int8.onnx
|
||||
rm -rf exp/tensorboard
|
||||
|
||||
popd
|
||||
|
||||
mv -v $repo ./android/SherpaOnnx/app/src/main/assets/
|
||||
tree ./android/SherpaOnnx/app/src/main/assets/
|
||||
git checkout .
|
||||
|
||||
pushd android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx
|
||||
sed -i.bak s/"type = 0"/"type = 3"/ ./MainActivity.kt
|
||||
git diff
|
||||
popd
|
||||
|
||||
for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
log "------------------------------------------------------------"
|
||||
log "build apk for $arch"
|
||||
log "------------------------------------------------------------"
|
||||
src_arch=$arch
|
||||
if [ $arch == "armeabi-v7a" ]; then
|
||||
src_arch=armv7-eabi
|
||||
elif [ $arch == "x86_64" ]; then
|
||||
src_arch=x86-64
|
||||
fi
|
||||
|
||||
ls -lh ./build-android-$src_arch/install/lib/*.so
|
||||
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnx
|
||||
./gradlew build
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnx/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-zh.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnx/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
|
||||
git checkout .
|
||||
|
||||
rm -rf ./android/SherpaOnnx/app/src/main/assets/$repo
|
||||
|
||||
# type 7, encoder int8, french
|
||||
log "https://huggingface.co/shaojieli/sherpa-onnx-streaming-zipformer-fr-2023-04-14"
|
||||
# see
|
||||
# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#shaojieli-sherpa-onnx-streaming-zipformer-fr-2023-04-14-french
|
||||
|
||||
# Download the model
|
||||
repo_url=https://huggingface.co/shaojieli/sherpa-onnx-streaming-zipformer-fr-2023-04-14
|
||||
log "Start testing ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "Download pretrained model and test-data from $repo_url"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
|
||||
# remove .git to save spaces
|
||||
rm -rf .git
|
||||
rm -v .gitattributes
|
||||
rm -rf test_wavs
|
||||
rm -v README.md
|
||||
rm -v encoder-epoch-29-avg-9-with-averaged-model.onnx
|
||||
rm -v decoder-epoch-29-avg-9-with-averaged-model.int8.onnx
|
||||
rm -v joiner-epoch-29-avg-9-with-averaged-model.int8.onnx
|
||||
rm -v export*.sh
|
||||
|
||||
popd
|
||||
|
||||
mv -v $repo ./android/SherpaOnnx/app/src/main/assets/
|
||||
tree ./android/SherpaOnnx/app/src/main/assets/
|
||||
git checkout .
|
||||
|
||||
pushd android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx
|
||||
sed -i.bak s/"type = 0"/"type = 7"/ ./MainActivity.kt
|
||||
git diff
|
||||
popd
|
||||
|
||||
for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
log "------------------------------------------------------------"
|
||||
log "build apk for $arch"
|
||||
log "------------------------------------------------------------"
|
||||
src_arch=$arch
|
||||
if [ $arch == "armeabi-v7a" ]; then
|
||||
src_arch=armv7-eabi
|
||||
elif [ $arch == "x86_64" ]; then
|
||||
src_arch=x86-64
|
||||
fi
|
||||
|
||||
ls -lh ./build-android-$src_arch/install/lib/*.so
|
||||
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnx
|
||||
./gradlew build
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnx/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-fr.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnx/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
|
||||
git checkout .
|
||||
|
||||
rm -rf ./android/SherpaOnnx/app/src/main/assets/$repo
|
||||
|
||||
# type 8, encoder int8, Binglual English + Chinese
|
||||
log "https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20"
|
||||
# see
|
||||
# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#csukuangfj-sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20-bilingual-chinese-english
|
||||
|
||||
# Download the model
|
||||
repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20
|
||||
log "Start testing ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "Download pretrained model and test-data from $repo_url"
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
|
||||
# remove .git to save spaces
|
||||
rm -rf .git
|
||||
rm -v .gitattributes
|
||||
rm -rf test_wavs
|
||||
rm -v README.md
|
||||
rm -v export*.sh
|
||||
rm -v *state*
|
||||
rm -v encoder-epoch-99-avg-1.onnx
|
||||
rm -v decoder-epoch-99-avg-1.int8.onnx
|
||||
rm -v joiner-epoch-99-avg-1.int8.onnx
|
||||
|
||||
popd
|
||||
|
||||
mv -v $repo ./android/SherpaOnnx/app/src/main/assets/
|
||||
tree ./android/SherpaOnnx/app/src/main/assets/
|
||||
git checkout .
|
||||
|
||||
pushd android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx
|
||||
sed -i.bak s/"type = 0"/"type = 8"/ ./MainActivity.kt
|
||||
git diff
|
||||
popd
|
||||
|
||||
for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
log "------------------------------------------------------------"
|
||||
log "build apk for $arch"
|
||||
log "------------------------------------------------------------"
|
||||
src_arch=$arch
|
||||
if [ $arch == "armeabi-v7a" ]; then
|
||||
src_arch=armv7-eabi
|
||||
elif [ $arch == "x86_64" ]; then
|
||||
src_arch=x86-64
|
||||
fi
|
||||
|
||||
ls -lh ./build-android-$src_arch/install/lib/*.so
|
||||
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnx
|
||||
./gradlew build
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnx/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-bilingual-en-zh.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnx/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
|
||||
git checkout .
|
||||
|
||||
rm -rf ./android/SherpaOnnx/app/src/main/assets/$repo
|
||||
|
||||
ls -lh apks/
|
||||
109
scripts/apk/build-apk-asr-2pass.sh.in
Normal file
109
scripts/apk/build-apk-asr-2pass.sh.in
Normal file
@@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Auto generated! Please DO NOT EDIT!
|
||||
|
||||
# Please set the environment variable ANDROID_NDK
|
||||
# before running this script
|
||||
|
||||
# Inside the $ANDROID_NDK directory, you can find a binary ndk-build
|
||||
# and some other files like the file "build/cmake/android.toolchain.cmake"
|
||||
|
||||
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]}) $*"
|
||||
}
|
||||
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
|
||||
log "Building streaming ASR two-pass APK for sherpa-onnx v${SHERPA_ONNX_VERSION}"
|
||||
|
||||
export SHERPA_ONNX_ENABLE_TTS=OFF
|
||||
|
||||
log "====================arm64-v8a================="
|
||||
./build-android-arm64-v8a.sh
|
||||
log "====================armv7-eabi================"
|
||||
./build-android-armv7-eabi.sh
|
||||
log "====================x86-64===================="
|
||||
./build-android-x86-64.sh
|
||||
log "====================x86===================="
|
||||
./build-android-x86.sh
|
||||
|
||||
mkdir -p apks
|
||||
|
||||
{% for first, second in model_list %}
|
||||
pushd ./android/SherpaOnnx2Pass/app/src/main/assets/
|
||||
|
||||
model_name1={{ first.model_name }}
|
||||
model_name=$model_name1
|
||||
type1={{ first.idx }}
|
||||
lang1={{ first.lang }}
|
||||
short_name1={{ first.short_name }}
|
||||
|
||||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/${model_name1}.tar.bz2
|
||||
tar xvf ${model_name1}.tar.bz2
|
||||
|
||||
{{ first.cmd }}
|
||||
|
||||
rm -rf *.tar.bz2
|
||||
ls -lh $model_name1
|
||||
|
||||
model_name2={{ second.model_name }}
|
||||
model_name=$model_name2
|
||||
type2={{ second.idx }}
|
||||
lang2={{ second.lang }}
|
||||
short_name2={{ second.short_name }}
|
||||
|
||||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/${model_name2}.tar.bz2
|
||||
tar xvf ${model_name2}.tar.bz2
|
||||
|
||||
{{ second.cmd }}
|
||||
|
||||
rm -rf *.tar.bz2
|
||||
ls -lh $model_name2
|
||||
|
||||
popd
|
||||
# Now we are at the project root directory
|
||||
|
||||
git checkout .
|
||||
pushd android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx
|
||||
sed -i.bak s/"firstType = 9/firstType = $type1/" ./MainActivity.kt
|
||||
sed -i.bak s/"secondType = 0/secondType = $type2/" ./MainActivity.kt
|
||||
git diff
|
||||
popd
|
||||
|
||||
for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
log "------------------------------------------------------------"
|
||||
log "build ASR apk for $arch"
|
||||
log "------------------------------------------------------------"
|
||||
src_arch=$arch
|
||||
if [ $arch == "armeabi-v7a" ]; then
|
||||
src_arch=armv7-eabi
|
||||
elif [ $arch == "x86_64" ]; then
|
||||
src_arch=x86-64
|
||||
fi
|
||||
|
||||
ls -lh ./build-android-$src_arch/install/lib/*.so
|
||||
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnx2Pass
|
||||
sed -i.bak s/2048/9012/g ./gradle.properties
|
||||
git diff ./gradle.properties
|
||||
./gradlew assembleRelease
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnx2Pass/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-asr_2pass-$lang1-${short_name1}_${short_name2}.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
|
||||
rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$model_name1
|
||||
rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$model_name2
|
||||
{% endfor %}
|
||||
|
||||
git checkout .
|
||||
|
||||
ls -lh apks/
|
||||
@@ -18,6 +18,8 @@ SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " "
|
||||
|
||||
log "Building keyword spotting APK for sherpa-onnx v${SHERPA_ONNX_VERSION}"
|
||||
|
||||
export SHERPA_ONNX_ENABLE_TTS=OFF
|
||||
|
||||
log "====================arm64-v8a================="
|
||||
./build-android-arm64-v8a.sh
|
||||
log "====================armv7-eabi================"
|
||||
@@ -34,14 +36,17 @@ repo=sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01
|
||||
|
||||
if [ ! -d ./android/SherpaOnnxKws/app/src/main/assets/$repo ]; then
|
||||
|
||||
repo_url=https://github.com/pkufool/keyword-spotting-models/releases/download/v0.1/sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01.tar.bz
|
||||
repo_url=https://github.com/k2-fsa/sherpa-onnx/releases/download/kws-models/sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01.tar.bz2
|
||||
log "Start testing ${repo_url}"
|
||||
|
||||
log "Download pretrained model and test-data from $repo_url"
|
||||
wget -c -qq $repo_url
|
||||
tar jxvf ${repo}.tar.bz
|
||||
log "Download pretrained model from $repo_url"
|
||||
curl -SL -O $repo_url
|
||||
tar jxvf ${repo}.tar.bz2
|
||||
rm ${repo}.tar.bz2
|
||||
|
||||
pushd $repo
|
||||
rm configuration.json
|
||||
rm keywords_raw.txt
|
||||
rm *.int8.onnx
|
||||
rm README.md
|
||||
rm -rfv test_wavs
|
||||
@@ -69,10 +74,13 @@ for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnxKws
|
||||
./gradlew build
|
||||
sed -i.bak s/2048/9012/g ./gradle.properties
|
||||
git diff ./gradle.properties
|
||||
./gradlew assembleRelease
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-kws-wenetspeech-zh-${SHERPA_ONNX_VERSION}-$arch.apk
|
||||
mv android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-zh-wenetspeech-zipformer.apk
|
||||
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
@@ -85,13 +93,16 @@ rm -rf ./android/SherpaOnnxKws/app/src/main/assets/$repo
|
||||
repo=sherpa-onnx-kws-zipformer-gigaspeech-3.3M-2024-01-01
|
||||
|
||||
if [ ! -d ./android/SherpaOnnxKws/app/src/main/assets/$repo ]; then
|
||||
repo_url=https://github.com/pkufool/keyword-spotting-models/releases/download/v0.1/sherpa-onnx-kws-zipformer-gigaspeech-3.3M-2024-01-01.tar.bz
|
||||
repo_url=https://github.com/k2-fsa/sherpa-onnx/releases/download/kws-models/sherpa-onnx-kws-zipformer-gigaspeech-3.3M-2024-01-01.tar.bz2
|
||||
log "Start testing ${repo_url}"
|
||||
log "Download pretrained model and test-data from $repo_url"
|
||||
wget -qq $repo_url
|
||||
tar jxvf ${repo}.tar.bz
|
||||
log "Download pretrained model from $repo_url"
|
||||
curl -SL -O $repo_url
|
||||
tar jxvf ${repo}.tar.bz2
|
||||
rm ${repo}.tar.bz2
|
||||
|
||||
pushd $repo
|
||||
rm bpe.model
|
||||
rm keywords_raw.txt
|
||||
rm *.int8.onnx
|
||||
rm README.md
|
||||
rm -rfv test_wavs
|
||||
@@ -124,10 +135,12 @@ for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnxKws
|
||||
./gradlew build
|
||||
sed -i.bak s/2048/9012/g ./gradle.properties
|
||||
git diff ./gradle.properties
|
||||
./gradlew assembleRelease
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-kws-gigaspeech-en-${SHERPA_ONNX_VERSION}-$arch.apk
|
||||
mv android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-en-gigaspeech-zipformer.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
93
scripts/apk/build-apk-vad-asr.sh.in
Normal file
93
scripts/apk/build-apk-vad-asr.sh.in
Normal file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Auto generated! Please DO NOT EDIT!
|
||||
|
||||
# Please set the environment variable ANDROID_NDK
|
||||
# before running this script
|
||||
|
||||
# Inside the $ANDROID_NDK directory, you can find a binary ndk-build
|
||||
# and some other files like the file "build/cmake/android.toolchain.cmake"
|
||||
|
||||
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]}) $*"
|
||||
}
|
||||
|
||||
SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
|
||||
|
||||
log "Building streaming VAD + ASR APK for sherpa-onnx v${SHERPA_ONNX_VERSION}"
|
||||
|
||||
export SHERPA_ONNX_ENABLE_TTS=OFF
|
||||
|
||||
log "====================arm64-v8a================="
|
||||
./build-android-arm64-v8a.sh
|
||||
log "====================armv7-eabi================"
|
||||
./build-android-armv7-eabi.sh
|
||||
log "====================x86-64===================="
|
||||
./build-android-x86-64.sh
|
||||
log "====================x86===================="
|
||||
./build-android-x86.sh
|
||||
|
||||
mkdir -p apks
|
||||
|
||||
{% for model in model_list %}
|
||||
pushd ./android/SherpaOnnxVadAsr/app/src/main/assets/
|
||||
model_name={{ model.model_name }}
|
||||
type={{ model.idx }}
|
||||
lang={{ model.lang }}
|
||||
short_name={{ model.short_name }}
|
||||
|
||||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/${model_name}.tar.bz2
|
||||
tar xvf ${model_name}.tar.bz2
|
||||
|
||||
{{ model.cmd }}
|
||||
|
||||
rm -rf *.tar.bz2
|
||||
ls -lh $model_name
|
||||
|
||||
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx
|
||||
|
||||
popd
|
||||
# Now we are at the project root directory
|
||||
|
||||
git checkout .
|
||||
pushd android/SherpaOnnxVadAsr/app/src/main/java/com/k2fsa/sherpa/onnx
|
||||
sed -i.bak s/"asrModelType = 0/asrModelType = $type/" ./MainActivity.kt
|
||||
git diff
|
||||
popd
|
||||
|
||||
for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
log "------------------------------------------------------------"
|
||||
log "build ASR apk for $arch"
|
||||
log "------------------------------------------------------------"
|
||||
src_arch=$arch
|
||||
if [ $arch == "armeabi-v7a" ]; then
|
||||
src_arch=armv7-eabi
|
||||
elif [ $arch == "x86_64" ]; then
|
||||
src_arch=x86-64
|
||||
fi
|
||||
|
||||
ls -lh ./build-android-$src_arch/install/lib/*.so
|
||||
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxVadAsr/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnxVadAsr
|
||||
sed -i.bak s/2048/9012/g ./gradle.properties
|
||||
git diff ./gradle.properties
|
||||
./gradlew assembleRelease
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnxVadAsr/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-vad_asr-$lang-$short_name.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnxVadAsr/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
|
||||
rm -rf ./android/SherpaOnnxVadAsr/app/src/main/assets/$model_name
|
||||
{% endfor %}
|
||||
|
||||
git checkout .
|
||||
|
||||
ls -lh apks/
|
||||
@@ -18,6 +18,8 @@ SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " "
|
||||
|
||||
log "Building APK for sherpa-onnx v${SHERPA_ONNX_VERSION}"
|
||||
|
||||
export SHERPA_ONNX_ENABLE_TTS=OFF
|
||||
|
||||
log "====================arm64-v8a================="
|
||||
./build-android-arm64-v8a.sh
|
||||
log "====================armv7-eabi================"
|
||||
@@ -53,10 +55,12 @@ for arch in arm64-v8a armeabi-v7a x86_64 x86; do
|
||||
cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxVad/app/src/main/jniLibs/$arch/
|
||||
|
||||
pushd ./android/SherpaOnnxVad
|
||||
./gradlew build
|
||||
sed -i.bak s/2048/9012/g ./gradle.properties
|
||||
git diff ./gradle.properties
|
||||
./gradlew assembleRelease
|
||||
popd
|
||||
|
||||
mv android/SherpaOnnxVad/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-silero-vad.apk
|
||||
mv android/SherpaOnnxVad/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-silero_vad.apk
|
||||
ls -lh apks
|
||||
rm -v ./android/SherpaOnnxVad/app/src/main/jniLibs/$arch/*.so
|
||||
done
|
||||
326
scripts/apk/generate-asr-2pass-apk-script.py
Executable file
326
scripts/apk/generate-asr-2pass-apk-script.py
Executable file
@@ -0,0 +1,326 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Optional
|
||||
|
||||
import jinja2
|
||||
|
||||
|
||||
def get_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--total",
|
||||
type=int,
|
||||
default=1,
|
||||
help="Number of runners",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--index",
|
||||
type=int,
|
||||
default=0,
|
||||
help="Index of the current runner",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@dataclass
|
||||
class Model:
|
||||
# We will download
|
||||
# https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/{model_name}.tar.bz2
|
||||
model_name: str
|
||||
|
||||
# The type of the model, e..g, 0, 1, 2. It is hardcoded in the kotlin code
|
||||
idx: int
|
||||
|
||||
# e.g., zh, en, zh_en
|
||||
lang: str
|
||||
|
||||
# e.g., whisper, paraformer, zipformer
|
||||
short_name: str = ""
|
||||
|
||||
# cmd is used to remove extra file from the model directory
|
||||
cmd: str = ""
|
||||
|
||||
|
||||
def get_2nd_models():
|
||||
models = [
|
||||
Model(
|
||||
model_name="sherpa-onnx-whisper-tiny.en",
|
||||
idx=2,
|
||||
lang="en",
|
||||
short_name="whisper_tiny",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v tiny.en-encoder.onnx
|
||||
rm -v tiny.en-decoder.onnx
|
||||
rm -rf test_wavs
|
||||
rm -v *.py
|
||||
rm -v requirements.txt
|
||||
rm -v .gitignore
|
||||
rm -v README.md
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-paraformer-zh-2023-03-28",
|
||||
idx=0,
|
||||
lang="zh",
|
||||
short_name="paraformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
|
||||
rm -v README.md
|
||||
rm -rfv test_wavs
|
||||
rm model.onnx
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="icefall-asr-zipformer-wenetspeech-20230615",
|
||||
idx=4,
|
||||
lang="zh",
|
||||
short_name="zipformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
|
||||
rm -rfv test_wavs
|
||||
rm -v README.md
|
||||
mv -v data/lang_char/tokens.txt ./
|
||||
rm -rfv data/lang_char
|
||||
|
||||
mv -v exp/encoder-epoch-12-avg-4.int8.onnx ./
|
||||
mv -v exp/decoder-epoch-12-avg-4.onnx ./
|
||||
mv -v exp/joiner-epoch-12-avg-4.int8.onnx ./
|
||||
rm -rfv exp
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
]
|
||||
return models
|
||||
|
||||
|
||||
def get_1st_models():
|
||||
# See as ./generate-asr-apk-script.py
|
||||
models = [
|
||||
Model(
|
||||
model_name="sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20",
|
||||
idx=8,
|
||||
lang="bilingual_zh_en",
|
||||
short_name="zipformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v decoder-epoch-99-avg-1.int8.onnx
|
||||
rm -v encoder-epoch-99-avg-1.onnx
|
||||
rm -v joiner-epoch-99-avg-1.onnx
|
||||
|
||||
rm -v *.sh
|
||||
rm -v bpe.model
|
||||
rm -v README.md
|
||||
rm -v .gitattributes
|
||||
rm -v *state*
|
||||
rm -rfv test_wavs
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-streaming-zipformer-en-2023-06-26",
|
||||
idx=6,
|
||||
lang="en",
|
||||
short_name="zipformer2",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v encoder-epoch-99-avg-1-chunk-16-left-128.onnx
|
||||
rm -v decoder-epoch-99-avg-1-chunk-16-left-128.int8.onnx
|
||||
rm -v joiner-epoch-99-avg-1-chunk-16-left-128.int8.onnx
|
||||
|
||||
rm -v README.md
|
||||
rm -v bpe.model
|
||||
rm -rfv test_wavs
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="icefall-asr-zipformer-streaming-wenetspeech-20230615",
|
||||
idx=3,
|
||||
lang="zh",
|
||||
short_name="zipformer2",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v exp/encoder-epoch-12-avg-4-chunk-16-left-128.onnx
|
||||
rm -v exp/decoder-epoch-12-avg-4-chunk-16-left-128.int8.onnx
|
||||
rm -v exp/joiner-epoch-12-avg-4-chunk-16-left-128.int8.onnx
|
||||
|
||||
rm -v data/lang_char/lexicon.txt
|
||||
rm -v data/lang_char/words.txt
|
||||
rm -rfv test_wavs
|
||||
rm -v README.md
|
||||
|
||||
ls -lh exp/
|
||||
ls -lh data/lang_char
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-streaming-zipformer-fr-2023-04-14",
|
||||
idx=7,
|
||||
lang="fr",
|
||||
short_name="zipformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v encoder-epoch-29-avg-9-with-averaged-model.onnx
|
||||
rm -v decoder-epoch-29-avg-9-with-averaged-model.int8.onnx
|
||||
rm -v joiner-epoch-29-avg-9-with-averaged-model.int8.onnx
|
||||
|
||||
rm -v *.sh
|
||||
rm -rf test_wavs
|
||||
rm README.md
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23",
|
||||
idx=9,
|
||||
lang="zh",
|
||||
short_name="small_zipformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v encoder-epoch-99-avg-1.onnx
|
||||
rm -v decoder-epoch-99-avg-1.int8.onnx
|
||||
rm -v joiner-epoch-99-avg-1.onnx
|
||||
|
||||
rm -v *.sh
|
||||
rm -rf test_wavs
|
||||
rm README.md
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-streaming-zipformer-en-20M-2023-02-17",
|
||||
idx=10,
|
||||
lang="en",
|
||||
short_name="small_zipformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v encoder-epoch-99-avg-1.onnx
|
||||
rm -v decoder-epoch-99-avg-1.int8.onnx
|
||||
rm -v joiner-epoch-99-avg-1.onnx
|
||||
|
||||
rm -v *.sh
|
||||
rm -rf test_wavs
|
||||
rm README.md
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
]
|
||||
|
||||
return models
|
||||
|
||||
|
||||
def get_models():
|
||||
first = get_1st_models()
|
||||
second = get_2nd_models()
|
||||
|
||||
combinations = [
|
||||
(
|
||||
"sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23",
|
||||
"sherpa-onnx-paraformer-zh-2023-03-28",
|
||||
),
|
||||
(
|
||||
"sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23",
|
||||
"icefall-asr-zipformer-wenetspeech-20230615",
|
||||
),
|
||||
(
|
||||
"sherpa-onnx-streaming-zipformer-en-20M-2023-02-17",
|
||||
"sherpa-onnx-whisper-tiny.en",
|
||||
),
|
||||
]
|
||||
models = []
|
||||
for f, s in combinations:
|
||||
t = []
|
||||
for m in first:
|
||||
if m.model_name == f:
|
||||
t.append(m)
|
||||
break
|
||||
assert len(t) == 1, (f, s, first, second)
|
||||
|
||||
for m in second:
|
||||
if m.model_name == s:
|
||||
t.append(m)
|
||||
break
|
||||
assert len(t) == 2, (f, s, first, second)
|
||||
|
||||
models.append(t)
|
||||
|
||||
return models
|
||||
|
||||
|
||||
def main():
|
||||
args = get_args()
|
||||
index = args.index
|
||||
total = args.total
|
||||
assert 0 <= index < total, (index, total)
|
||||
|
||||
all_model_list = get_models()
|
||||
|
||||
num_models = len(all_model_list)
|
||||
|
||||
num_per_runner = num_models // total
|
||||
if num_per_runner <= 0:
|
||||
raise ValueError(f"num_models: {num_models}, num_runners: {total}")
|
||||
|
||||
start = index * num_per_runner
|
||||
end = start + num_per_runner
|
||||
|
||||
remaining = num_models - args.total * num_per_runner
|
||||
|
||||
print(f"{index}/{total}: {start}-{end}/{num_models}")
|
||||
|
||||
d = dict()
|
||||
d["model_list"] = all_model_list[start:end]
|
||||
if index < remaining:
|
||||
s = args.total * num_per_runner + index
|
||||
d["model_list"].append(all_model_list[s])
|
||||
print(f"{s}/{num_models}")
|
||||
|
||||
filename_list = [
|
||||
"./build-apk-asr-2pass.sh",
|
||||
]
|
||||
for filename in filename_list:
|
||||
environment = jinja2.Environment()
|
||||
with open(f"{filename}.in") as f:
|
||||
s = f.read()
|
||||
template = environment.from_string(s)
|
||||
|
||||
s = template.render(**d)
|
||||
with open(filename, "w") as f:
|
||||
print(s, file=f)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -57,12 +57,116 @@ def get_models():
|
||||
rm -v joiner-epoch-99-avg-1.onnx
|
||||
|
||||
rm -v *.sh
|
||||
rm -v bpe.model
|
||||
rm -v README.md
|
||||
rm -v .gitattributes
|
||||
rm -v *state*
|
||||
rm -rfv test_wavs
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-streaming-zipformer-en-2023-06-26",
|
||||
idx=6,
|
||||
lang="en",
|
||||
short_name="zipformer2",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v encoder-epoch-99-avg-1-chunk-16-left-128.onnx
|
||||
rm -v decoder-epoch-99-avg-1-chunk-16-left-128.int8.onnx
|
||||
rm -v joiner-epoch-99-avg-1-chunk-16-left-128.int8.onnx
|
||||
|
||||
rm -v README.md
|
||||
rm -v bpe.model
|
||||
rm -rfv test_wavs
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="icefall-asr-zipformer-streaming-wenetspeech-20230615",
|
||||
idx=3,
|
||||
lang="zh",
|
||||
short_name="zipformer2",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v exp/encoder-epoch-12-avg-4-chunk-16-left-128.onnx
|
||||
rm -v exp/decoder-epoch-12-avg-4-chunk-16-left-128.int8.onnx
|
||||
rm -v exp/joiner-epoch-12-avg-4-chunk-16-left-128.int8.onnx
|
||||
|
||||
rm -v data/lang_char/lexicon.txt
|
||||
rm -v data/lang_char/words.txt
|
||||
rm -rfv test_wavs
|
||||
rm -v README.md
|
||||
|
||||
ls -lh exp/
|
||||
ls -lh data/lang_char
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-streaming-zipformer-fr-2023-04-14",
|
||||
idx=7,
|
||||
lang="fr",
|
||||
short_name="zipformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v encoder-epoch-29-avg-9-with-averaged-model.onnx
|
||||
rm -v decoder-epoch-29-avg-9-with-averaged-model.int8.onnx
|
||||
rm -v joiner-epoch-29-avg-9-with-averaged-model.int8.onnx
|
||||
|
||||
rm -v *.sh
|
||||
rm -rf test_wavs
|
||||
rm README.md
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23",
|
||||
idx=9,
|
||||
lang="zh",
|
||||
short_name="small_zipformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v encoder-epoch-99-avg-1.onnx
|
||||
rm -v decoder-epoch-99-avg-1.int8.onnx
|
||||
rm -v joiner-epoch-99-avg-1.onnx
|
||||
|
||||
rm -v *.sh
|
||||
rm -rf test_wavs
|
||||
rm README.md
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-streaming-zipformer-en-20M-2023-02-17",
|
||||
idx=10,
|
||||
lang="en",
|
||||
short_name="small_zipformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v encoder-epoch-99-avg-1.onnx
|
||||
rm -v decoder-epoch-99-avg-1.int8.onnx
|
||||
rm -v joiner-epoch-99-avg-1.onnx
|
||||
|
||||
rm -v *.sh
|
||||
rm -rf test_wavs
|
||||
rm README.md
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
|
||||
156
scripts/apk/generate-vad-asr-apk-script.py
Executable file
156
scripts/apk/generate-vad-asr-apk-script.py
Executable file
@@ -0,0 +1,156 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Optional
|
||||
|
||||
import jinja2
|
||||
|
||||
|
||||
def get_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"--total",
|
||||
type=int,
|
||||
default=1,
|
||||
help="Number of runners",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--index",
|
||||
type=int,
|
||||
default=0,
|
||||
help="Index of the current runner",
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@dataclass
|
||||
class Model:
|
||||
# We will download
|
||||
# https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/{model_name}.tar.bz2
|
||||
model_name: str
|
||||
|
||||
# The type of the model, e..g, 0, 1, 2. It is hardcoded in the kotlin code
|
||||
idx: int
|
||||
|
||||
# e.g., zh, en, zh_en
|
||||
lang: str
|
||||
|
||||
# e.g., whisper, paraformer, zipformer
|
||||
short_name: str = ""
|
||||
|
||||
# cmd is used to remove extra file from the model directory
|
||||
cmd: str = ""
|
||||
|
||||
|
||||
# See get_2nd_models() in ./generate-asr-2pass-apk-script.py
|
||||
def get_models():
|
||||
models = [
|
||||
Model(
|
||||
model_name="sherpa-onnx-whisper-tiny.en",
|
||||
idx=2,
|
||||
lang="en",
|
||||
short_name="whisper_tiny",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
rm -v tiny.en-encoder.onnx
|
||||
rm -v tiny.en-decoder.onnx
|
||||
rm -rf test_wavs
|
||||
rm -v *.py
|
||||
rm -v requirements.txt
|
||||
rm -v .gitignore
|
||||
rm -v README.md
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="sherpa-onnx-paraformer-zh-2023-03-28",
|
||||
idx=0,
|
||||
lang="zh",
|
||||
short_name="paraformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
|
||||
rm -v README.md
|
||||
rm -rfv test_wavs
|
||||
rm model.onnx
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
Model(
|
||||
model_name="icefall-asr-zipformer-wenetspeech-20230615",
|
||||
idx=4,
|
||||
lang="zh",
|
||||
short_name="zipformer",
|
||||
cmd="""
|
||||
pushd $model_name
|
||||
|
||||
rm -rfv test_wavs
|
||||
rm -v README.md
|
||||
mv -v data/lang_char/tokens.txt ./
|
||||
rm -rfv data/lang_char
|
||||
|
||||
mv -v exp/encoder-epoch-12-avg-4.int8.onnx ./
|
||||
mv -v exp/decoder-epoch-12-avg-4.onnx ./
|
||||
mv -v exp/joiner-epoch-12-avg-4.int8.onnx ./
|
||||
rm -rfv exp
|
||||
|
||||
ls -lh
|
||||
|
||||
popd
|
||||
""",
|
||||
),
|
||||
]
|
||||
return models
|
||||
|
||||
|
||||
def main():
|
||||
args = get_args()
|
||||
index = args.index
|
||||
total = args.total
|
||||
assert 0 <= index < total, (index, total)
|
||||
|
||||
all_model_list = get_models()
|
||||
|
||||
num_models = len(all_model_list)
|
||||
|
||||
num_per_runner = num_models // total
|
||||
if num_per_runner <= 0:
|
||||
raise ValueError(f"num_models: {num_models}, num_runners: {total}")
|
||||
|
||||
start = index * num_per_runner
|
||||
end = start + num_per_runner
|
||||
|
||||
remaining = num_models - args.total * num_per_runner
|
||||
|
||||
print(f"{index}/{total}: {start}-{end}/{num_models}")
|
||||
|
||||
d = dict()
|
||||
d["model_list"] = all_model_list[start:end]
|
||||
if index < remaining:
|
||||
s = args.total * num_per_runner + index
|
||||
d["model_list"].append(all_model_list[s])
|
||||
print(f"{s}/{num_models}")
|
||||
|
||||
filename_list = [
|
||||
"./build-apk-vad-asr.sh",
|
||||
]
|
||||
for filename in filename_list:
|
||||
environment = jinja2.Environment()
|
||||
with open(f"{filename}.in") as f:
|
||||
s = f.read()
|
||||
template = environment.from_string(s)
|
||||
|
||||
s = template.render(**d)
|
||||
with open(filename, "w") as f:
|
||||
print(s, file=f)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user