Committed by
GitHub
Add links to pre-built APKs and pre-trained models to README. (#840)
正在显示
20 个修改的文件
包含
1395 行增加
和
614 行删除
.github/workflows/apk-asr-2pass.yaml
0 → 100644
| 1 | +name: apk-asr-2pass | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + push: | ||
| 5 | + tags: | ||
| 6 | + - '*' | ||
| 7 | + | ||
| 8 | + workflow_dispatch: | ||
| 9 | + | ||
| 10 | +concurrency: | ||
| 11 | + group: apk-asr-2pass-${{ github.ref }} | ||
| 12 | + cancel-in-progress: true | ||
| 13 | + | ||
| 14 | +permissions: | ||
| 15 | + contents: write | ||
| 16 | + | ||
| 17 | +jobs: | ||
| 18 | + apk_asr_2pass: | ||
| 19 | + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' | ||
| 20 | + runs-on: ${{ matrix.os }} | ||
| 21 | + name: apk for asr ${{ matrix.index }}/${{ matrix.total }} | ||
| 22 | + strategy: | ||
| 23 | + fail-fast: false | ||
| 24 | + matrix: | ||
| 25 | + os: [ubuntu-latest] | ||
| 26 | + total: ["2"] | ||
| 27 | + index: ["0", "1"] | ||
| 28 | + | ||
| 29 | + steps: | ||
| 30 | + - uses: actions/checkout@v4 | ||
| 31 | + with: | ||
| 32 | + fetch-depth: 0 | ||
| 33 | + | ||
| 34 | + # https://github.com/actions/setup-java | ||
| 35 | + - uses: actions/setup-java@v4 | ||
| 36 | + with: | ||
| 37 | + distribution: 'temurin' # See 'Supported distributions' for available options | ||
| 38 | + java-version: '21' | ||
| 39 | + | ||
| 40 | + - name: ccache | ||
| 41 | + uses: hendrikmuhs/ccache-action@v1.2 | ||
| 42 | + with: | ||
| 43 | + key: ${{ matrix.os }}-android | ||
| 44 | + | ||
| 45 | + - name: Display NDK HOME | ||
| 46 | + shell: bash | ||
| 47 | + run: | | ||
| 48 | + echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}" | ||
| 49 | + ls -lh ${ANDROID_NDK_LATEST_HOME} | ||
| 50 | + | ||
| 51 | + - name: Install Python dependencies | ||
| 52 | + shell: bash | ||
| 53 | + run: | | ||
| 54 | + python3 -m pip install --upgrade pip jinja2 | ||
| 55 | + | ||
| 56 | + - name: Setup build tool version variable | ||
| 57 | + shell: bash | ||
| 58 | + run: | | ||
| 59 | + echo "---" | ||
| 60 | + ls -lh /usr/local/lib/android/ | ||
| 61 | + echo "---" | ||
| 62 | + | ||
| 63 | + ls -lh /usr/local/lib/android/sdk | ||
| 64 | + echo "---" | ||
| 65 | + | ||
| 66 | + ls -lh /usr/local/lib/android/sdk/build-tools | ||
| 67 | + echo "---" | ||
| 68 | + | ||
| 69 | + BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | ||
| 70 | + echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | ||
| 71 | + echo "Last build tool version is: $BUILD_TOOL_VERSION" | ||
| 72 | + | ||
| 73 | + - name: Generate build script | ||
| 74 | + shell: bash | ||
| 75 | + run: | | ||
| 76 | + cd scripts/apk | ||
| 77 | + | ||
| 78 | + total=${{ matrix.total }} | ||
| 79 | + index=${{ matrix.index }} | ||
| 80 | + | ||
| 81 | + ./generate-asr-2pass-apk-script.py --total $total --index $index | ||
| 82 | + | ||
| 83 | + chmod +x build-apk-asr-2pass.sh | ||
| 84 | + mv -v ./build-apk-asr-2pass.sh ../.. | ||
| 85 | + | ||
| 86 | + - name: build APK | ||
| 87 | + shell: bash | ||
| 88 | + run: | | ||
| 89 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 90 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 91 | + cmake --version | ||
| 92 | + | ||
| 93 | + export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME | ||
| 94 | + ./build-apk-asr-2pass.sh | ||
| 95 | + | ||
| 96 | + - name: Display APK | ||
| 97 | + shell: bash | ||
| 98 | + run: | | ||
| 99 | + ls -lh ./apks/ | ||
| 100 | + du -h -d1 . | ||
| 101 | + | ||
| 102 | + # https://github.com/marketplace/actions/sign-android-release | ||
| 103 | + - uses: r0adkll/sign-android-release@v1 | ||
| 104 | + name: Sign app APK | ||
| 105 | + with: | ||
| 106 | + releaseDirectory: ./apks | ||
| 107 | + signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }} | ||
| 108 | + alias: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }} | ||
| 109 | + keyStorePassword: ${{ secrets.ANDROID_SIGNING_KEY_STORE_PASSWORD }} | ||
| 110 | + env: | ||
| 111 | + BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} | ||
| 112 | + | ||
| 113 | + - name: Display APK after signing | ||
| 114 | + shell: bash | ||
| 115 | + run: | | ||
| 116 | + ls -lh ./apks/ | ||
| 117 | + du -h -d1 . | ||
| 118 | + | ||
| 119 | + - name: Rename APK after signing | ||
| 120 | + shell: bash | ||
| 121 | + run: | | ||
| 122 | + cd apks | ||
| 123 | + rm -fv signingKey.jks | ||
| 124 | + rm -fv *.apk.idsig | ||
| 125 | + rm -fv *-aligned.apk | ||
| 126 | + | ||
| 127 | + all_apks=$(ls -1 *-signed.apk) | ||
| 128 | + echo "----" | ||
| 129 | + echo $all_apks | ||
| 130 | + echo "----" | ||
| 131 | + for apk in ${all_apks[@]}; do | ||
| 132 | + n=$(echo $apk | sed -e s/-signed//) | ||
| 133 | + mv -v $apk $n | ||
| 134 | + done | ||
| 135 | + | ||
| 136 | + cd .. | ||
| 137 | + | ||
| 138 | + ls -lh ./apks/ | ||
| 139 | + du -h -d1 . | ||
| 140 | + | ||
| 141 | + - name: Display APK after rename | ||
| 142 | + shell: bash | ||
| 143 | + run: | | ||
| 144 | + ls -lh ./apks/ | ||
| 145 | + du -h -d1 . | ||
| 146 | + | ||
| 147 | + - name: Publish to huggingface | ||
| 148 | + env: | ||
| 149 | + HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
| 150 | + uses: nick-fields/retry@v3 | ||
| 151 | + with: | ||
| 152 | + max_attempts: 20 | ||
| 153 | + timeout_seconds: 200 | ||
| 154 | + shell: bash | ||
| 155 | + command: | | ||
| 156 | + git config --global user.email "csukuangfj@gmail.com" | ||
| 157 | + git config --global user.name "Fangjun Kuang" | ||
| 158 | + | ||
| 159 | + rm -rf huggingface | ||
| 160 | + export GIT_LFS_SKIP_SMUDGE=1 | ||
| 161 | + | ||
| 162 | + git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface | ||
| 163 | + cd huggingface | ||
| 164 | + git fetch | ||
| 165 | + git pull | ||
| 166 | + git merge -m "merge remote" --ff origin main | ||
| 167 | + | ||
| 168 | + mkdir -p asr-2pass | ||
| 169 | + cp -v ../apks/*.apk ./asr-2pass/ | ||
| 170 | + git status | ||
| 171 | + git lfs track "*.apk" | ||
| 172 | + git add . | ||
| 173 | + git commit -m "add more apks" | ||
| 174 | + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk main |
| @@ -23,8 +23,8 @@ jobs: | @@ -23,8 +23,8 @@ jobs: | ||
| 23 | fail-fast: false | 23 | fail-fast: false |
| 24 | matrix: | 24 | matrix: |
| 25 | os: [ubuntu-latest] | 25 | os: [ubuntu-latest] |
| 26 | - total: ["1"] | ||
| 27 | - index: ["0"] | 26 | + total: ["3"] |
| 27 | + index: ["0", "1", "2"] | ||
| 28 | 28 | ||
| 29 | steps: | 29 | steps: |
| 30 | - uses: actions/checkout@v4 | 30 | - uses: actions/checkout@v4 |
| @@ -16,11 +16,15 @@ permissions: | @@ -16,11 +16,15 @@ permissions: | ||
| 16 | 16 | ||
| 17 | jobs: | 17 | jobs: |
| 18 | apk_kws: | 18 | apk_kws: |
| 19 | + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' | ||
| 19 | runs-on: ${{ matrix.os }} | 20 | runs-on: ${{ matrix.os }} |
| 21 | + name: apk for kws ${{ matrix.index }}/${{ matrix.total }} | ||
| 20 | strategy: | 22 | strategy: |
| 21 | fail-fast: false | 23 | fail-fast: false |
| 22 | matrix: | 24 | matrix: |
| 23 | os: [ubuntu-latest] | 25 | os: [ubuntu-latest] |
| 26 | + total: ["1"] | ||
| 27 | + index: ["0"] | ||
| 24 | 28 | ||
| 25 | steps: | 29 | steps: |
| 26 | - uses: actions/checkout@v4 | 30 | - uses: actions/checkout@v4 |
| @@ -44,6 +48,11 @@ jobs: | @@ -44,6 +48,11 @@ jobs: | ||
| 44 | echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}" | 48 | echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}" |
| 45 | ls -lh ${ANDROID_NDK_LATEST_HOME} | 49 | ls -lh ${ANDROID_NDK_LATEST_HOME} |
| 46 | 50 | ||
| 51 | + - name: Install Python dependencies | ||
| 52 | + shell: bash | ||
| 53 | + run: | | ||
| 54 | + python3 -m pip install --upgrade pip jinja2 | ||
| 55 | + | ||
| 47 | - name: Setup build tool version variable | 56 | - name: Setup build tool version variable |
| 48 | shell: bash | 57 | shell: bash |
| 49 | run: | | 58 | run: | |
| @@ -61,6 +70,16 @@ jobs: | @@ -61,6 +70,16 @@ jobs: | ||
| 61 | echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | 70 | echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV |
| 62 | echo "Last build tool version is: $BUILD_TOOL_VERSION" | 71 | echo "Last build tool version is: $BUILD_TOOL_VERSION" |
| 63 | 72 | ||
| 73 | + - name: Generate build script | ||
| 74 | + shell: bash | ||
| 75 | + run: | | ||
| 76 | + cd scripts/apk | ||
| 77 | + | ||
| 78 | + total=${{ matrix.total }} | ||
| 79 | + index=${{ matrix.index }} | ||
| 80 | + | ||
| 81 | + mv -v ./build-apk-kws.sh ../.. | ||
| 82 | + | ||
| 64 | - name: build APK | 83 | - name: build APK |
| 65 | shell: bash | 84 | shell: bash |
| 66 | run: | | 85 | run: | |
| @@ -69,13 +88,13 @@ jobs: | @@ -69,13 +88,13 @@ jobs: | ||
| 69 | cmake --version | 88 | cmake --version |
| 70 | 89 | ||
| 71 | export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME | 90 | export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME |
| 72 | - ./build-kws-apk.sh | 91 | + ./build-apk-kws.sh |
| 73 | 92 | ||
| 74 | - name: Display APK | 93 | - name: Display APK |
| 75 | shell: bash | 94 | shell: bash |
| 76 | run: | | 95 | run: | |
| 77 | ls -lh ./apks/ | 96 | ls -lh ./apks/ |
| 78 | - | 97 | + du -h -d1 . |
| 79 | 98 | ||
| 80 | # https://github.com/marketplace/actions/sign-android-release | 99 | # https://github.com/marketplace/actions/sign-android-release |
| 81 | - uses: r0adkll/sign-android-release@v1 | 100 | - uses: r0adkll/sign-android-release@v1 |
.github/workflows/apk-vad-asr.yaml
0 → 100644
| 1 | +name: apk-vad-asr | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + push: | ||
| 5 | + tags: | ||
| 6 | + - '*' | ||
| 7 | + | ||
| 8 | + workflow_dispatch: | ||
| 9 | + | ||
| 10 | +concurrency: | ||
| 11 | + group: apk-vad-asr-${{ github.ref }} | ||
| 12 | + cancel-in-progress: true | ||
| 13 | + | ||
| 14 | +permissions: | ||
| 15 | + contents: write | ||
| 16 | + | ||
| 17 | +jobs: | ||
| 18 | + apk_vad_asr: | ||
| 19 | + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' | ||
| 20 | + runs-on: ${{ matrix.os }} | ||
| 21 | + name: apk for asr ${{ matrix.index }}/${{ matrix.total }} | ||
| 22 | + strategy: | ||
| 23 | + fail-fast: false | ||
| 24 | + matrix: | ||
| 25 | + os: [ubuntu-latest] | ||
| 26 | + total: ["3"] | ||
| 27 | + index: ["0", "1", "2"] | ||
| 28 | + | ||
| 29 | + steps: | ||
| 30 | + - uses: actions/checkout@v4 | ||
| 31 | + with: | ||
| 32 | + fetch-depth: 0 | ||
| 33 | + | ||
| 34 | + # https://github.com/actions/setup-java | ||
| 35 | + - uses: actions/setup-java@v4 | ||
| 36 | + with: | ||
| 37 | + distribution: 'temurin' # See 'Supported distributions' for available options | ||
| 38 | + java-version: '21' | ||
| 39 | + | ||
| 40 | + - name: ccache | ||
| 41 | + uses: hendrikmuhs/ccache-action@v1.2 | ||
| 42 | + with: | ||
| 43 | + key: ${{ matrix.os }}-android | ||
| 44 | + | ||
| 45 | + - name: Display NDK HOME | ||
| 46 | + shell: bash | ||
| 47 | + run: | | ||
| 48 | + echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}" | ||
| 49 | + ls -lh ${ANDROID_NDK_LATEST_HOME} | ||
| 50 | + | ||
| 51 | + - name: Install Python dependencies | ||
| 52 | + shell: bash | ||
| 53 | + run: | | ||
| 54 | + python3 -m pip install --upgrade pip jinja2 | ||
| 55 | + | ||
| 56 | + - name: Setup build tool version variable | ||
| 57 | + shell: bash | ||
| 58 | + run: | | ||
| 59 | + echo "---" | ||
| 60 | + ls -lh /usr/local/lib/android/ | ||
| 61 | + echo "---" | ||
| 62 | + | ||
| 63 | + ls -lh /usr/local/lib/android/sdk | ||
| 64 | + echo "---" | ||
| 65 | + | ||
| 66 | + ls -lh /usr/local/lib/android/sdk/build-tools | ||
| 67 | + echo "---" | ||
| 68 | + | ||
| 69 | + BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | ||
| 70 | + echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | ||
| 71 | + echo "Last build tool version is: $BUILD_TOOL_VERSION" | ||
| 72 | + | ||
| 73 | + - name: Generate build script | ||
| 74 | + shell: bash | ||
| 75 | + run: | | ||
| 76 | + cd scripts/apk | ||
| 77 | + | ||
| 78 | + total=${{ matrix.total }} | ||
| 79 | + index=${{ matrix.index }} | ||
| 80 | + | ||
| 81 | + ./generate-vad-asr-apk-script.py --total $total --index $index | ||
| 82 | + | ||
| 83 | + chmod +x build-apk-vad-asr.sh | ||
| 84 | + mv -v ./build-apk-vad-asr.sh ../.. | ||
| 85 | + | ||
| 86 | + - name: build APK | ||
| 87 | + shell: bash | ||
| 88 | + run: | | ||
| 89 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 90 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 91 | + cmake --version | ||
| 92 | + | ||
| 93 | + export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME | ||
| 94 | + ./build-apk-vad-asr.sh | ||
| 95 | + | ||
| 96 | + - name: Display APK | ||
| 97 | + shell: bash | ||
| 98 | + run: | | ||
| 99 | + ls -lh ./apks/ | ||
| 100 | + du -h -d1 . | ||
| 101 | + | ||
| 102 | + # https://github.com/marketplace/actions/sign-android-release | ||
| 103 | + - uses: r0adkll/sign-android-release@v1 | ||
| 104 | + name: Sign app APK | ||
| 105 | + with: | ||
| 106 | + releaseDirectory: ./apks | ||
| 107 | + signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }} | ||
| 108 | + alias: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }} | ||
| 109 | + keyStorePassword: ${{ secrets.ANDROID_SIGNING_KEY_STORE_PASSWORD }} | ||
| 110 | + env: | ||
| 111 | + BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} | ||
| 112 | + | ||
| 113 | + - name: Display APK after signing | ||
| 114 | + shell: bash | ||
| 115 | + run: | | ||
| 116 | + ls -lh ./apks/ | ||
| 117 | + du -h -d1 . | ||
| 118 | + | ||
| 119 | + - name: Rename APK after signing | ||
| 120 | + shell: bash | ||
| 121 | + run: | | ||
| 122 | + cd apks | ||
| 123 | + rm -fv signingKey.jks | ||
| 124 | + rm -fv *.apk.idsig | ||
| 125 | + rm -fv *-aligned.apk | ||
| 126 | + | ||
| 127 | + all_apks=$(ls -1 *-signed.apk) | ||
| 128 | + echo "----" | ||
| 129 | + echo $all_apks | ||
| 130 | + echo "----" | ||
| 131 | + for apk in ${all_apks[@]}; do | ||
| 132 | + n=$(echo $apk | sed -e s/-signed//) | ||
| 133 | + mv -v $apk $n | ||
| 134 | + done | ||
| 135 | + | ||
| 136 | + cd .. | ||
| 137 | + | ||
| 138 | + ls -lh ./apks/ | ||
| 139 | + du -h -d1 . | ||
| 140 | + | ||
| 141 | + - name: Display APK after rename | ||
| 142 | + shell: bash | ||
| 143 | + run: | | ||
| 144 | + ls -lh ./apks/ | ||
| 145 | + du -h -d1 . | ||
| 146 | + | ||
| 147 | + - name: Publish to huggingface | ||
| 148 | + env: | ||
| 149 | + HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
| 150 | + uses: nick-fields/retry@v3 | ||
| 151 | + with: | ||
| 152 | + max_attempts: 20 | ||
| 153 | + timeout_seconds: 200 | ||
| 154 | + shell: bash | ||
| 155 | + command: | | ||
| 156 | + git config --global user.email "csukuangfj@gmail.com" | ||
| 157 | + git config --global user.name "Fangjun Kuang" | ||
| 158 | + | ||
| 159 | + rm -rf huggingface | ||
| 160 | + export GIT_LFS_SKIP_SMUDGE=1 | ||
| 161 | + | ||
| 162 | + git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface | ||
| 163 | + cd huggingface | ||
| 164 | + git fetch | ||
| 165 | + git pull | ||
| 166 | + git merge -m "merge remote" --ff origin main | ||
| 167 | + | ||
| 168 | + mkdir -p vad-asr | ||
| 169 | + cp -v ../apks/*.apk ./vad-asr/ | ||
| 170 | + git status | ||
| 171 | + git lfs track "*.apk" | ||
| 172 | + git add . | ||
| 173 | + git commit -m "add more apks" | ||
| 174 | + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk main |
.github/workflows/apk-vad.yaml
0 → 100644
| 1 | +name: apk-vad | ||
| 2 | + | ||
| 3 | +on: | ||
| 4 | + push: | ||
| 5 | + tags: | ||
| 6 | + - '*' | ||
| 7 | + | ||
| 8 | + workflow_dispatch: | ||
| 9 | + | ||
| 10 | +concurrency: | ||
| 11 | + group: apk-vad-${{ github.ref }} | ||
| 12 | + cancel-in-progress: true | ||
| 13 | + | ||
| 14 | +permissions: | ||
| 15 | + contents: write | ||
| 16 | + | ||
| 17 | +jobs: | ||
| 18 | + apk_vad: | ||
| 19 | + if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' | ||
| 20 | + runs-on: ${{ matrix.os }} | ||
| 21 | + name: apk for vad ${{ matrix.index }}/${{ matrix.total }} | ||
| 22 | + strategy: | ||
| 23 | + fail-fast: false | ||
| 24 | + matrix: | ||
| 25 | + os: [ubuntu-latest] | ||
| 26 | + total: ["1"] | ||
| 27 | + index: ["0"] | ||
| 28 | + | ||
| 29 | + steps: | ||
| 30 | + - uses: actions/checkout@v4 | ||
| 31 | + with: | ||
| 32 | + fetch-depth: 0 | ||
| 33 | + | ||
| 34 | + # https://github.com/actions/setup-java | ||
| 35 | + - uses: actions/setup-java@v4 | ||
| 36 | + with: | ||
| 37 | + distribution: 'temurin' # See 'Supported distributions' for available options | ||
| 38 | + java-version: '21' | ||
| 39 | + | ||
| 40 | + - name: ccache | ||
| 41 | + uses: hendrikmuhs/ccache-action@v1.2 | ||
| 42 | + with: | ||
| 43 | + key: ${{ matrix.os }}-android | ||
| 44 | + | ||
| 45 | + - name: Display NDK HOME | ||
| 46 | + shell: bash | ||
| 47 | + run: | | ||
| 48 | + echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}" | ||
| 49 | + ls -lh ${ANDROID_NDK_LATEST_HOME} | ||
| 50 | + | ||
| 51 | + - name: Install Python dependencies | ||
| 52 | + shell: bash | ||
| 53 | + run: | | ||
| 54 | + python3 -m pip install --upgrade pip jinja2 | ||
| 55 | + | ||
| 56 | + - name: Setup build tool version variable | ||
| 57 | + shell: bash | ||
| 58 | + run: | | ||
| 59 | + echo "---" | ||
| 60 | + ls -lh /usr/local/lib/android/ | ||
| 61 | + echo "---" | ||
| 62 | + | ||
| 63 | + ls -lh /usr/local/lib/android/sdk | ||
| 64 | + echo "---" | ||
| 65 | + | ||
| 66 | + ls -lh /usr/local/lib/android/sdk/build-tools | ||
| 67 | + echo "---" | ||
| 68 | + | ||
| 69 | + BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | ||
| 70 | + echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | ||
| 71 | + echo "Last build tool version is: $BUILD_TOOL_VERSION" | ||
| 72 | + | ||
| 73 | + - name: Generate build script | ||
| 74 | + shell: bash | ||
| 75 | + run: | | ||
| 76 | + cd scripts/apk | ||
| 77 | + | ||
| 78 | + total=${{ matrix.total }} | ||
| 79 | + index=${{ matrix.index }} | ||
| 80 | + | ||
| 81 | + mv -v ./build-apk-vad.sh ../.. | ||
| 82 | + | ||
| 83 | + - name: build APK | ||
| 84 | + shell: bash | ||
| 85 | + run: | | ||
| 86 | + export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 87 | + export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 88 | + cmake --version | ||
| 89 | + | ||
| 90 | + export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME | ||
| 91 | + ./build-apk-vad.sh | ||
| 92 | + | ||
| 93 | + - name: Display APK | ||
| 94 | + shell: bash | ||
| 95 | + run: | | ||
| 96 | + ls -lh ./apks/ | ||
| 97 | + du -h -d1 . | ||
| 98 | + | ||
| 99 | + # https://github.com/marketplace/actions/sign-android-release | ||
| 100 | + - uses: r0adkll/sign-android-release@v1 | ||
| 101 | + name: Sign app APK | ||
| 102 | + with: | ||
| 103 | + releaseDirectory: ./apks | ||
| 104 | + signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }} | ||
| 105 | + alias: ${{ secrets.ANDROID_SIGNING_KEY_ALIAS }} | ||
| 106 | + keyStorePassword: ${{ secrets.ANDROID_SIGNING_KEY_STORE_PASSWORD }} | ||
| 107 | + env: | ||
| 108 | + BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} | ||
| 109 | + | ||
| 110 | + - name: Display APK after signing | ||
| 111 | + shell: bash | ||
| 112 | + run: | | ||
| 113 | + ls -lh ./apks/ | ||
| 114 | + du -h -d1 . | ||
| 115 | + | ||
| 116 | + - name: Rename APK after signing | ||
| 117 | + shell: bash | ||
| 118 | + run: | | ||
| 119 | + cd apks | ||
| 120 | + rm -fv signingKey.jks | ||
| 121 | + rm -fv *.apk.idsig | ||
| 122 | + rm -fv *-aligned.apk | ||
| 123 | + | ||
| 124 | + all_apks=$(ls -1 *-signed.apk) | ||
| 125 | + echo "----" | ||
| 126 | + echo $all_apks | ||
| 127 | + echo "----" | ||
| 128 | + for apk in ${all_apks[@]}; do | ||
| 129 | + n=$(echo $apk | sed -e s/-signed//) | ||
| 130 | + mv -v $apk $n | ||
| 131 | + done | ||
| 132 | + | ||
| 133 | + cd .. | ||
| 134 | + | ||
| 135 | + ls -lh ./apks/ | ||
| 136 | + du -h -d1 . | ||
| 137 | + | ||
| 138 | + - name: Display APK after rename | ||
| 139 | + shell: bash | ||
| 140 | + run: | | ||
| 141 | + ls -lh ./apks/ | ||
| 142 | + du -h -d1 . | ||
| 143 | + | ||
| 144 | + - name: Publish to huggingface | ||
| 145 | + env: | ||
| 146 | + HF_TOKEN: ${{ secrets.HF_TOKEN }} | ||
| 147 | + uses: nick-fields/retry@v3 | ||
| 148 | + with: | ||
| 149 | + max_attempts: 20 | ||
| 150 | + timeout_seconds: 200 | ||
| 151 | + shell: bash | ||
| 152 | + command: | | ||
| 153 | + git config --global user.email "csukuangfj@gmail.com" | ||
| 154 | + git config --global user.name "Fangjun Kuang" | ||
| 155 | + | ||
| 156 | + rm -rf huggingface | ||
| 157 | + export GIT_LFS_SKIP_SMUDGE=1 | ||
| 158 | + | ||
| 159 | + git clone https://huggingface.co/csukuangfj/sherpa-onnx-apk huggingface | ||
| 160 | + cd huggingface | ||
| 161 | + git fetch | ||
| 162 | + git pull | ||
| 163 | + git merge -m "merge remote" --ff origin main | ||
| 164 | + | ||
| 165 | + mkdir -p vad | ||
| 166 | + cp -v ../apks/*.apk ./vad/ | ||
| 167 | + git status | ||
| 168 | + git lfs track "*.apk" | ||
| 169 | + git add . | ||
| 170 | + git commit -m "add more apks" | ||
| 171 | + git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-apk main |
.github/workflows/apk.yaml
已删除
100644 → 0
| 1 | -name: apk | ||
| 2 | - | ||
| 3 | -on: | ||
| 4 | - push: | ||
| 5 | - tags: | ||
| 6 | - - '*' | ||
| 7 | - | ||
| 8 | - workflow_dispatch: | ||
| 9 | - | ||
| 10 | -concurrency: | ||
| 11 | - group: apk-${{ github.ref }} | ||
| 12 | - cancel-in-progress: true | ||
| 13 | - | ||
| 14 | -permissions: | ||
| 15 | - contents: write | ||
| 16 | - | ||
| 17 | -jobs: | ||
| 18 | - apk: | ||
| 19 | - runs-on: ${{ matrix.os }} | ||
| 20 | - strategy: | ||
| 21 | - fail-fast: false | ||
| 22 | - matrix: | ||
| 23 | - os: [ubuntu-latest] | ||
| 24 | - | ||
| 25 | - steps: | ||
| 26 | - - uses: actions/checkout@v4 | ||
| 27 | - with: | ||
| 28 | - fetch-depth: 0 | ||
| 29 | - | ||
| 30 | - # https://github.com/actions/setup-java | ||
| 31 | - - uses: actions/setup-java@v4 | ||
| 32 | - with: | ||
| 33 | - distribution: 'temurin' # See 'Supported distributions' for available options | ||
| 34 | - java-version: '21' | ||
| 35 | - | ||
| 36 | - - name: ccache | ||
| 37 | - uses: hendrikmuhs/ccache-action@v1.2 | ||
| 38 | - with: | ||
| 39 | - key: ${{ matrix.os }}-android | ||
| 40 | - | ||
| 41 | - - name: Display NDK HOME | ||
| 42 | - shell: bash | ||
| 43 | - run: | | ||
| 44 | - echo "ANDROID_NDK_LATEST_HOME: ${ANDROID_NDK_LATEST_HOME}" | ||
| 45 | - ls -lh ${ANDROID_NDK_LATEST_HOME} | ||
| 46 | - | ||
| 47 | - - name: build APK | ||
| 48 | - shell: bash | ||
| 49 | - run: | | ||
| 50 | - export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
| 51 | - export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
| 52 | - cmake --version | ||
| 53 | - | ||
| 54 | - export ANDROID_NDK=$ANDROID_NDK_LATEST_HOME | ||
| 55 | - ./build-apk-vad.sh | ||
| 56 | - ./build-apk-two-pass.sh | ||
| 57 | - ./build-apk.sh | ||
| 58 | - | ||
| 59 | - - name: Display APK | ||
| 60 | - shell: bash | ||
| 61 | - run: | | ||
| 62 | - ls -lh ./apks/ | ||
| 63 | - | ||
| 64 | - - uses: actions/upload-artifact@v4 | ||
| 65 | - with: | ||
| 66 | - path: ./apks/*.apk | ||
| 67 | - | ||
| 68 | - - name: Release APK | ||
| 69 | - uses: svenstaro/upload-release-action@v2 | ||
| 70 | - with: | ||
| 71 | - file_glob: true | ||
| 72 | - file: apks/*.apk | ||
| 73 | - overwrite: true |
| @@ -39,7 +39,7 @@ jobs: | @@ -39,7 +39,7 @@ jobs: | ||
| 39 | strategy: | 39 | strategy: |
| 40 | fail-fast: false | 40 | fail-fast: false |
| 41 | matrix: | 41 | matrix: |
| 42 | - os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04, windows-latest] | 42 | + os: [macos-11, macos-14, ubuntu-20.04, ubuntu-22.04] #, windows-latest] |
| 43 | node-version: ["16", "17", "18", "19", "21", "22"] | 43 | node-version: ["16", "17", "18", "19", "21", "22"] |
| 44 | python-version: ["3.8"] | 44 | python-version: ["3.8"] |
| 45 | 45 |
| @@ -37,12 +37,37 @@ with the following APIs | @@ -37,12 +37,37 @@ with the following APIs | ||
| 37 | - Kotlin | 37 | - Kotlin |
| 38 | - Swift | 38 | - Swift |
| 39 | 39 | ||
| 40 | +# Links for pre-built Android APKs | ||
| 41 | + | ||
| 42 | +| Description | URL | 中国用户 | | ||
| 43 | +|--------------------------------|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------| | ||
| 44 | +| 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) | | ||
| 45 | +| 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) | | ||
| 46 | +|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)| | ||
| 47 | +|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)| | ||
| 48 | +|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)| | ||
| 49 | +| 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) | | ||
| 50 | +| 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) | | ||
| 51 | +| 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) | | ||
| 52 | +| 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) | | ||
| 53 | +|Keyword spotting| [Address](https://k2-fsa.github.io/sherpa/onnx/kws/apk.html)| [点此](https://k2-fsa.github.io/sherpa/onnx/kws/apk-cn.html)| | ||
| 54 | + | ||
| 55 | +# Links for pre-trained models | ||
| 56 | + | ||
| 57 | +| Description | URL | | ||
| 58 | +|--------------------------------|--------------------------------------------------------------------------------------------------------------------------------| | ||
| 59 | +| Speech recognition (speech to text, ASR) | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/asr-models) | | ||
| 60 | +| Text-to-speech (TTS) | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/tts-models) | | ||
| 61 | +| VAD | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx)| | ||
| 62 | +| Keyword spotting |[Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/kws-models)| | ||
| 63 | +| Audio tagging | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/audio-tagging-models)| | ||
| 64 | +| Speaker identification (Speaker ID) | [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/speaker-recongition-models)| | ||
| 65 | +| 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) | | ||
| 66 | +| Punctuation| [Address](https://github.com/k2-fsa/sherpa-onnx/releases/tag/punctuation-models)| | ||
| 67 | + | ||
| 40 | # Useful links | 68 | # Useful links |
| 41 | 69 | ||
| 42 | - Documentation: https://k2-fsa.github.io/sherpa/onnx/ | 70 | - Documentation: https://k2-fsa.github.io/sherpa/onnx/ |
| 43 | -- APK for the text-to-speech engine: https://k2-fsa.github.io/sherpa/onnx/tts/apk-engine.html | ||
| 44 | -- APK for speaker identification: https://k2-fsa.github.io/sherpa/onnx/speaker-identification/apk.html | ||
| 45 | -- APK for speech recognition: https://github.com/k2-fsa/sherpa-onnx/releases/ | ||
| 46 | - Bilibili 演示视频: https://search.bilibili.com/all?keyword=%E6%96%B0%E4%B8%80%E4%BB%A3Kaldi | 71 | - Bilibili 演示视频: https://search.bilibili.com/all?keyword=%E6%96%B0%E4%B8%80%E4%BB%A3Kaldi |
| 47 | 72 | ||
| 48 | # How to reach us | 73 | # How to reach us |
| 1 | <resources> | 1 | <resources> |
| 2 | - <string name="app_name">VAD</string> | 2 | + <string name="app_name">VAD: Next-gen Kaldi</string> |
| 3 | 3 | ||
| 4 | <string name="hint">Click the Start button to play Silero VAD with Next-gen Kaldi.</string> | 4 | <string name="hint">Click the Start button to play Silero VAD with Next-gen Kaldi.</string> |
| 5 | <string name="start">Start</string> | 5 | <string name="start">Start</string> |
| @@ -8,7 +8,6 @@ import android.media.MediaRecorder | @@ -8,7 +8,6 @@ import android.media.MediaRecorder | ||
| 8 | import android.os.Bundle | 8 | import android.os.Bundle |
| 9 | import android.text.method.ScrollingMovementMethod | 9 | import android.text.method.ScrollingMovementMethod |
| 10 | import android.util.Log | 10 | import android.util.Log |
| 11 | -import android.view.View | ||
| 12 | import android.widget.Button | 11 | import android.widget.Button |
| 13 | import android.widget.TextView | 12 | import android.widget.TextView |
| 14 | import androidx.appcompat.app.AppCompatActivity | 13 | import androidx.appcompat.app.AppCompatActivity |
| @@ -200,12 +199,12 @@ class MainActivity : AppCompatActivity() { | @@ -200,12 +199,12 @@ class MainActivity : AppCompatActivity() { | ||
| 200 | // Please change getOfflineModelConfig() to add new models | 199 | // Please change getOfflineModelConfig() to add new models |
| 201 | // See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html | 200 | // See https://k2-fsa.github.io/sherpa/onnx/pretrained_models/index.html |
| 202 | // for a list of available models | 201 | // for a list of available models |
| 203 | - val secondType = 0 | ||
| 204 | - Log.i(TAG, "Select model type ${secondType} for the second pass") | 202 | + val asrModelType = 0 |
| 203 | + Log.i(TAG, "Select model type ${asrModelType} for ASR") | ||
| 205 | 204 | ||
| 206 | val config = OfflineRecognizerConfig( | 205 | val config = OfflineRecognizerConfig( |
| 207 | featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80), | 206 | featConfig = getFeatureConfig(sampleRate = sampleRateInHz, featureDim = 80), |
| 208 | - modelConfig = getOfflineModelConfig(type = secondType)!!, | 207 | + modelConfig = getOfflineModelConfig(type = asrModelType)!!, |
| 209 | ) | 208 | ) |
| 210 | 209 | ||
| 211 | offlineRecognizer = OfflineRecognizer( | 210 | offlineRecognizer = OfflineRecognizer( |
| 1 | <resources> | 1 | <resources> |
| 2 | - <string name="app_name">VAD+ASR</string> | 2 | + <string name="app_name">VAD+ASR: Next-gen Kaldi</string> |
| 3 | <string name="hint">Click the Start button to play speech-to-text with Next-gen Kaldi. | 3 | <string name="hint">Click the Start button to play speech-to-text with Next-gen Kaldi. |
| 4 | \n | 4 | \n |
| 5 | \n\n\n | 5 | \n\n\n |
build-apk-two-pass.sh
已删除
100755 → 0
| 1 | -#!/usr/bin/env bash | ||
| 2 | - | ||
| 3 | -# Please set the environment variable ANDROID_NDK | ||
| 4 | -# before running this script | ||
| 5 | - | ||
| 6 | -# Inside the $ANDROID_NDK directory, you can find a binary ndk-build | ||
| 7 | -# and some other files like the file "build/cmake/android.toolchain.cmake" | ||
| 8 | - | ||
| 9 | -set -e | ||
| 10 | - | ||
| 11 | -log() { | ||
| 12 | - # This function is from espnet | ||
| 13 | - local fname=${BASH_SOURCE[1]##*/} | ||
| 14 | - echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*" | ||
| 15 | -} | ||
| 16 | - | ||
| 17 | -SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 18 | - | ||
| 19 | -log "Building two-pass APK for sherpa-onnx v${SHERPA_ONNX_VERSION}" | ||
| 20 | - | ||
| 21 | -log "====================arm64-v8a=================" | ||
| 22 | -./build-android-arm64-v8a.sh | ||
| 23 | -log "====================armv7-eabi================" | ||
| 24 | -./build-android-armv7-eabi.sh | ||
| 25 | -log "====================x86-64====================" | ||
| 26 | -./build-android-x86-64.sh | ||
| 27 | -log "====================x86====================" | ||
| 28 | -./build-android-x86.sh | ||
| 29 | - | ||
| 30 | -mkdir -p apks | ||
| 31 | - | ||
| 32 | -log "Download 1st pass streaming model (English)" | ||
| 33 | - | ||
| 34 | -# Download the model | ||
| 35 | -# 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 | ||
| 36 | -repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-en-20M-2023-02-17 | ||
| 37 | -log "$repo_url" | ||
| 38 | - | ||
| 39 | -log "Start downloading ${repo_url}" | ||
| 40 | -repo=$(basename $repo_url) | ||
| 41 | -log "Download pretrained model from $repo_url" | ||
| 42 | -GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url | ||
| 43 | -pushd $repo | ||
| 44 | -git lfs pull --include "*.onnx" | ||
| 45 | - | ||
| 46 | -# remove .git to save spaces | ||
| 47 | -rm -rf .git | ||
| 48 | -rm README.md | ||
| 49 | -rm -rf test_wavs | ||
| 50 | -rm .gitattributes | ||
| 51 | -rm export-onnx*.sh | ||
| 52 | - | ||
| 53 | -rm encoder-epoch-99-avg-1.onnx | ||
| 54 | -rm decoder-epoch-99-avg-1.int8.onnx | ||
| 55 | -rm joiner-epoch-99-avg-1.onnx | ||
| 56 | - | ||
| 57 | -ls -lh | ||
| 58 | -popd | ||
| 59 | - | ||
| 60 | -mv -v $repo ./android/SherpaOnnx2Pass/app/src/main/assets/ | ||
| 61 | -tree ./android/SherpaOnnx2Pass/app/src/main/assets/ | ||
| 62 | -repo_1st=$repo | ||
| 63 | - | ||
| 64 | -# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/whisper/tiny.en.html | ||
| 65 | -repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-whisper-tiny.en | ||
| 66 | -log "$repo_url" | ||
| 67 | - | ||
| 68 | -log "Start downloading ${repo_url}" | ||
| 69 | -repo=$(basename $repo_url) | ||
| 70 | -log "Download pretrained model from $repo_url" | ||
| 71 | -GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url | ||
| 72 | -pushd $repo | ||
| 73 | -git lfs pull --include "*.onnx" | ||
| 74 | - | ||
| 75 | -# remove .git to save spaces | ||
| 76 | -rm -rf .git | ||
| 77 | -rm -fv README.md | ||
| 78 | -rm -rf test_wavs | ||
| 79 | -rm .gitattributes | ||
| 80 | - | ||
| 81 | -rm -fv *.ort | ||
| 82 | -rm tiny.en-encoder.onnx | ||
| 83 | -rm tiny.en-decoder.onnx | ||
| 84 | - | ||
| 85 | -ls -lh | ||
| 86 | -popd | ||
| 87 | - | ||
| 88 | -mv -v $repo ./android/SherpaOnnx2Pass/app/src/main/assets/ | ||
| 89 | -tree ./android/SherpaOnnx2Pass/app/src/main/assets/ | ||
| 90 | -repo_2nd=$repo | ||
| 91 | - | ||
| 92 | -pushd android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx | ||
| 93 | -# sed -i.bak s/"firstType = 1"/"firstType = 1"/ ./MainActivity.kt | ||
| 94 | -sed -i.bak s/"secondType = 1"/"secondType = 2"/ ./MainActivity.kt | ||
| 95 | -git diff | ||
| 96 | -popd | ||
| 97 | - | ||
| 98 | -for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 99 | - log "------------------------------------------------------------" | ||
| 100 | - log "build apk for $arch" | ||
| 101 | - log "------------------------------------------------------------" | ||
| 102 | - src_arch=$arch | ||
| 103 | - if [ $arch == "armeabi-v7a" ]; then | ||
| 104 | - src_arch=armv7-eabi | ||
| 105 | - elif [ $arch == "x86_64" ]; then | ||
| 106 | - src_arch=x86-64 | ||
| 107 | - fi | ||
| 108 | - | ||
| 109 | - ls -lh ./build-android-$src_arch/install/lib/*.so | ||
| 110 | - | ||
| 111 | - cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/ | ||
| 112 | - | ||
| 113 | - pushd ./android/SherpaOnnx2Pass | ||
| 114 | - ./gradlew build | ||
| 115 | - popd | ||
| 116 | - | ||
| 117 | - mv android/SherpaOnnx2Pass/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-en-2pass-whisper-tiny.en.apk | ||
| 118 | - ls -lh apks | ||
| 119 | - rm -v ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/*.so | ||
| 120 | -done | ||
| 121 | - | ||
| 122 | -git checkout . | ||
| 123 | - | ||
| 124 | -rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$repo_1st | ||
| 125 | -rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$repo_2nd | ||
| 126 | - | ||
| 127 | -log "==================================================" | ||
| 128 | -log " two-pass Chinese " | ||
| 129 | -log "==================================================" | ||
| 130 | - | ||
| 131 | -log "Download 1st pass streaming model (Chinese)" | ||
| 132 | -# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#sherpa-onnx-streaming-zipformer-zh-14m-2023-02-23 | ||
| 133 | -repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23 | ||
| 134 | -log "$repo_url" | ||
| 135 | - | ||
| 136 | -log "Start downloading ${repo_url}" | ||
| 137 | -repo=$(basename $repo_url) | ||
| 138 | -log "Download pretrained model from $repo_url" | ||
| 139 | -GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url | ||
| 140 | -pushd $repo | ||
| 141 | -git lfs pull --include "*.onnx" | ||
| 142 | - | ||
| 143 | -# remove .git to save spaces | ||
| 144 | -rm -rf .git | ||
| 145 | -rm README.md | ||
| 146 | -rm -rf test_wavs | ||
| 147 | -rm .gitattributes | ||
| 148 | -rm export-onnx*.sh | ||
| 149 | - | ||
| 150 | -rm encoder-epoch-99-avg-1.onnx | ||
| 151 | -rm decoder-epoch-99-avg-1.int8.onnx | ||
| 152 | -rm joiner-epoch-99-avg-1.onnx | ||
| 153 | - | ||
| 154 | -ls -lh | ||
| 155 | -popd | ||
| 156 | - | ||
| 157 | -mv -v $repo ./android/SherpaOnnx2Pass/app/src/main/assets/ | ||
| 158 | -tree ./android/SherpaOnnx2Pass/app/src/main/assets/ | ||
| 159 | -repo_1st=$repo | ||
| 160 | - | ||
| 161 | -# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/offline-paraformer/paraformer-models.html#csukuangfj-sherpa-onnx-paraformer-zh-2023-03-28-chinese | ||
| 162 | -repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-paraformer-zh-2023-03-28 | ||
| 163 | -log "$repo_url" | ||
| 164 | - | ||
| 165 | -log "Start downloading ${repo_url}" | ||
| 166 | -repo=$(basename $repo_url) | ||
| 167 | -log "Download pretrained model from $repo_url" | ||
| 168 | -GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url | ||
| 169 | -pushd $repo | ||
| 170 | -git lfs pull --include "*.onnx" | ||
| 171 | - | ||
| 172 | -# remove .git to save spaces | ||
| 173 | -rm -rf .git | ||
| 174 | -rm README.md | ||
| 175 | -rm -rf test_wavs | ||
| 176 | -rm .gitattributes | ||
| 177 | - | ||
| 178 | -rm model.onnx | ||
| 179 | - | ||
| 180 | -ls -lh | ||
| 181 | -popd | ||
| 182 | - | ||
| 183 | -mv -v $repo ./android/SherpaOnnx2Pass/app/src/main/assets/ | ||
| 184 | -tree ./android/SherpaOnnx2Pass/app/src/main/assets/ | ||
| 185 | -repo_2nd=$repo | ||
| 186 | - | ||
| 187 | -pushd android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx | ||
| 188 | -sed -i.bak s/"firstType = 1"/"firstType = 0"/ ./MainActivity.kt | ||
| 189 | -sed -i.bak s/"secondType = 1"/"secondType = 0"/ ./MainActivity.kt | ||
| 190 | -git diff | ||
| 191 | -popd | ||
| 192 | - | ||
| 193 | -for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 194 | - log "------------------------------------------------------------" | ||
| 195 | - log "build apk for $arch" | ||
| 196 | - log "------------------------------------------------------------" | ||
| 197 | - src_arch=$arch | ||
| 198 | - if [ $arch == "armeabi-v7a" ]; then | ||
| 199 | - src_arch=armv7-eabi | ||
| 200 | - elif [ $arch == "x86_64" ]; then | ||
| 201 | - src_arch=x86-64 | ||
| 202 | - fi | ||
| 203 | - | ||
| 204 | - ls -lh ./build-android-$src_arch/install/lib/*.so | ||
| 205 | - | ||
| 206 | - cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/ | ||
| 207 | - | ||
| 208 | - pushd ./android/SherpaOnnx2Pass | ||
| 209 | - ./gradlew build | ||
| 210 | - popd | ||
| 211 | - | ||
| 212 | - mv android/SherpaOnnx2Pass/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-zh-2pass-paraformer.apk | ||
| 213 | - ls -lh apks | ||
| 214 | - rm -v ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/*.so | ||
| 215 | -done | ||
| 216 | - | ||
| 217 | -git checkout . | ||
| 218 | - | ||
| 219 | -rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$repo_1st | ||
| 220 | -rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$repo_2nd | ||
| 221 | - | ||
| 222 | -ls -lh apks/ |
build-apk.sh
已删除
100755 → 0
| 1 | -#!/usr/bin/env bash | ||
| 2 | - | ||
| 3 | -# Please set the environment variable ANDROID_NDK | ||
| 4 | -# before running this script | ||
| 5 | - | ||
| 6 | -# Inside the $ANDROID_NDK directory, you can find a binary ndk-build | ||
| 7 | -# and some other files like the file "build/cmake/android.toolchain.cmake" | ||
| 8 | - | ||
| 9 | -set -e | ||
| 10 | - | ||
| 11 | -log() { | ||
| 12 | - # This function is from espnet | ||
| 13 | - local fname=${BASH_SOURCE[1]##*/} | ||
| 14 | - echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*" | ||
| 15 | -} | ||
| 16 | - | ||
| 17 | -SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 18 | - | ||
| 19 | -log "Building APK for sherpa-onnx v${SHERPA_ONNX_VERSION}" | ||
| 20 | - | ||
| 21 | -log "====================arm64-v8a=================" | ||
| 22 | -./build-android-arm64-v8a.sh | ||
| 23 | -log "====================armv7-eabi================" | ||
| 24 | -./build-android-armv7-eabi.sh | ||
| 25 | -log "====================x86-64====================" | ||
| 26 | -./build-android-x86-64.sh | ||
| 27 | -log "====================x86====================" | ||
| 28 | -./build-android-x86.sh | ||
| 29 | - | ||
| 30 | - | ||
| 31 | -mkdir -p apks | ||
| 32 | - | ||
| 33 | -log "https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-en-2023-06-26" | ||
| 34 | - | ||
| 35 | -# Download the model | ||
| 36 | -# 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 | ||
| 37 | -repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-en-2023-06-26 | ||
| 38 | -log "Start testing ${repo_url}" | ||
| 39 | -repo=$(basename $repo_url) | ||
| 40 | -log "Download pretrained model and test-data from $repo_url" | ||
| 41 | -GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url | ||
| 42 | -pushd $repo | ||
| 43 | -git lfs pull --include "*.onnx" | ||
| 44 | - | ||
| 45 | -# remove .git to save spaces | ||
| 46 | -rm -rf .git | ||
| 47 | -rm README.md | ||
| 48 | -rm -v *64* | ||
| 49 | -rm -v encoder-epoch-99-avg-1-chunk-16-left-128.onnx | ||
| 50 | -rm -v decoder-epoch-99-avg-1-chunk-16-left-128.int8.onnx | ||
| 51 | -rm -v joiner-epoch-99-avg-1-chunk-16-left-128.int8.onnx | ||
| 52 | -rm -rfv test_wavs | ||
| 53 | -rm -v *.sh | ||
| 54 | -ls -lh | ||
| 55 | -popd | ||
| 56 | - | ||
| 57 | -mv -v $repo ./android/SherpaOnnx/app/src/main/assets/ | ||
| 58 | -tree ./android/SherpaOnnx/app/src/main/assets/ | ||
| 59 | - | ||
| 60 | -pushd android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx | ||
| 61 | -sed -i.bak s/"type = 0"/"type = 6"/ ./MainActivity.kt | ||
| 62 | -git diff | ||
| 63 | -popd | ||
| 64 | - | ||
| 65 | -for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 66 | - log "------------------------------------------------------------" | ||
| 67 | - log "build apk for $arch" | ||
| 68 | - log "------------------------------------------------------------" | ||
| 69 | - src_arch=$arch | ||
| 70 | - if [ $arch == "armeabi-v7a" ]; then | ||
| 71 | - src_arch=armv7-eabi | ||
| 72 | - elif [ $arch == "x86_64" ]; then | ||
| 73 | - src_arch=x86-64 | ||
| 74 | - fi | ||
| 75 | - | ||
| 76 | - ls -lh ./build-android-$src_arch/install/lib/*.so | ||
| 77 | - | ||
| 78 | - cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx/app/src/main/jniLibs/$arch/ | ||
| 79 | - | ||
| 80 | - pushd ./android/SherpaOnnx | ||
| 81 | - ./gradlew build | ||
| 82 | - popd | ||
| 83 | - | ||
| 84 | - mv android/SherpaOnnx/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-en.apk | ||
| 85 | - ls -lh apks | ||
| 86 | - rm -v ./android/SherpaOnnx/app/src/main/jniLibs/$arch/*.so | ||
| 87 | -done | ||
| 88 | - | ||
| 89 | -git checkout . | ||
| 90 | - | ||
| 91 | -rm -rf ./android/SherpaOnnx/app/src/main/assets/$repo | ||
| 92 | - | ||
| 93 | -# type 3, encoder int8, zh | ||
| 94 | -log "https://huggingface.co/pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615" | ||
| 95 | -# see | ||
| 96 | -# https://k2-fsa.github.io/sherpa/onnx/pretrained_models/online-transducer/zipformer-transducer-models.html#pkufool-icefall-asr-zipformer-streaming-wenetspeech-20230615-chinese | ||
| 97 | - | ||
| 98 | -# Download the model | ||
| 99 | -repo_url=https://huggingface.co/pkufool/icefall-asr-zipformer-streaming-wenetspeech-20230615 | ||
| 100 | -log "Start testing ${repo_url}" | ||
| 101 | -repo=$(basename $repo_url) | ||
| 102 | -log "Download pretrained model and test-data from $repo_url" | ||
| 103 | -GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url | ||
| 104 | -pushd $repo | ||
| 105 | -git lfs pull --include "*.onnx" | ||
| 106 | - | ||
| 107 | -# remove .git to save spaces | ||
| 108 | -rm -rf .git | ||
| 109 | -rm README.md | ||
| 110 | -rm -rf logs | ||
| 111 | -rm -rf scripts | ||
| 112 | -rm -rf test_wavs | ||
| 113 | -rm -rf data/.DS_Store | ||
| 114 | -rm data/lang_char/*.pt | ||
| 115 | -rm data/lang_char/lexicon.txt | ||
| 116 | -rm data/lang_char/words.txt | ||
| 117 | -rm -v exp/*.pt | ||
| 118 | -rm -v exp/*32* | ||
| 119 | -rm -v exp/*256* | ||
| 120 | -rm -v exp/encoder-epoch-12-avg-4-chunk-16-left-128.onnx | ||
| 121 | -rm -v exp/decoder-epoch-12-avg-4-chunk-16-left-128.int8.onnx | ||
| 122 | -rm -v exp/joiner-epoch-12-avg-4-chunk-16-left-128.int8.onnx | ||
| 123 | -rm -rf exp/tensorboard | ||
| 124 | - | ||
| 125 | -popd | ||
| 126 | - | ||
| 127 | -mv -v $repo ./android/SherpaOnnx/app/src/main/assets/ | ||
| 128 | -tree ./android/SherpaOnnx/app/src/main/assets/ | ||
| 129 | -git checkout . | ||
| 130 | - | ||
| 131 | -pushd android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx | ||
| 132 | -sed -i.bak s/"type = 0"/"type = 3"/ ./MainActivity.kt | ||
| 133 | -git diff | ||
| 134 | -popd | ||
| 135 | - | ||
| 136 | -for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 137 | - log "------------------------------------------------------------" | ||
| 138 | - log "build apk for $arch" | ||
| 139 | - log "------------------------------------------------------------" | ||
| 140 | - src_arch=$arch | ||
| 141 | - if [ $arch == "armeabi-v7a" ]; then | ||
| 142 | - src_arch=armv7-eabi | ||
| 143 | - elif [ $arch == "x86_64" ]; then | ||
| 144 | - src_arch=x86-64 | ||
| 145 | - fi | ||
| 146 | - | ||
| 147 | - ls -lh ./build-android-$src_arch/install/lib/*.so | ||
| 148 | - | ||
| 149 | - cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx/app/src/main/jniLibs/$arch/ | ||
| 150 | - | ||
| 151 | - pushd ./android/SherpaOnnx | ||
| 152 | - ./gradlew build | ||
| 153 | - popd | ||
| 154 | - | ||
| 155 | - mv android/SherpaOnnx/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-zh.apk | ||
| 156 | - ls -lh apks | ||
| 157 | - rm -v ./android/SherpaOnnx/app/src/main/jniLibs/$arch/*.so | ||
| 158 | -done | ||
| 159 | - | ||
| 160 | -git checkout . | ||
| 161 | - | ||
| 162 | -rm -rf ./android/SherpaOnnx/app/src/main/assets/$repo | ||
| 163 | - | ||
| 164 | -# type 7, encoder int8, french | ||
| 165 | -log "https://huggingface.co/shaojieli/sherpa-onnx-streaming-zipformer-fr-2023-04-14" | ||
| 166 | -# see | ||
| 167 | -# 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 | ||
| 168 | - | ||
| 169 | -# Download the model | ||
| 170 | -repo_url=https://huggingface.co/shaojieli/sherpa-onnx-streaming-zipformer-fr-2023-04-14 | ||
| 171 | -log "Start testing ${repo_url}" | ||
| 172 | -repo=$(basename $repo_url) | ||
| 173 | -log "Download pretrained model and test-data from $repo_url" | ||
| 174 | -GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url | ||
| 175 | -pushd $repo | ||
| 176 | -git lfs pull --include "*.onnx" | ||
| 177 | - | ||
| 178 | -# remove .git to save spaces | ||
| 179 | -rm -rf .git | ||
| 180 | -rm -v .gitattributes | ||
| 181 | -rm -rf test_wavs | ||
| 182 | -rm -v README.md | ||
| 183 | -rm -v encoder-epoch-29-avg-9-with-averaged-model.onnx | ||
| 184 | -rm -v decoder-epoch-29-avg-9-with-averaged-model.int8.onnx | ||
| 185 | -rm -v joiner-epoch-29-avg-9-with-averaged-model.int8.onnx | ||
| 186 | -rm -v export*.sh | ||
| 187 | - | ||
| 188 | -popd | ||
| 189 | - | ||
| 190 | -mv -v $repo ./android/SherpaOnnx/app/src/main/assets/ | ||
| 191 | -tree ./android/SherpaOnnx/app/src/main/assets/ | ||
| 192 | -git checkout . | ||
| 193 | - | ||
| 194 | -pushd android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx | ||
| 195 | -sed -i.bak s/"type = 0"/"type = 7"/ ./MainActivity.kt | ||
| 196 | -git diff | ||
| 197 | -popd | ||
| 198 | - | ||
| 199 | -for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 200 | - log "------------------------------------------------------------" | ||
| 201 | - log "build apk for $arch" | ||
| 202 | - log "------------------------------------------------------------" | ||
| 203 | - src_arch=$arch | ||
| 204 | - if [ $arch == "armeabi-v7a" ]; then | ||
| 205 | - src_arch=armv7-eabi | ||
| 206 | - elif [ $arch == "x86_64" ]; then | ||
| 207 | - src_arch=x86-64 | ||
| 208 | - fi | ||
| 209 | - | ||
| 210 | - ls -lh ./build-android-$src_arch/install/lib/*.so | ||
| 211 | - | ||
| 212 | - cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx/app/src/main/jniLibs/$arch/ | ||
| 213 | - | ||
| 214 | - pushd ./android/SherpaOnnx | ||
| 215 | - ./gradlew build | ||
| 216 | - popd | ||
| 217 | - | ||
| 218 | - mv android/SherpaOnnx/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-fr.apk | ||
| 219 | - ls -lh apks | ||
| 220 | - rm -v ./android/SherpaOnnx/app/src/main/jniLibs/$arch/*.so | ||
| 221 | -done | ||
| 222 | - | ||
| 223 | -git checkout . | ||
| 224 | - | ||
| 225 | -rm -rf ./android/SherpaOnnx/app/src/main/assets/$repo | ||
| 226 | - | ||
| 227 | -# type 8, encoder int8, Binglual English + Chinese | ||
| 228 | -log "https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20" | ||
| 229 | -# see | ||
| 230 | -# 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 | ||
| 231 | - | ||
| 232 | -# Download the model | ||
| 233 | -repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 | ||
| 234 | -log "Start testing ${repo_url}" | ||
| 235 | -repo=$(basename $repo_url) | ||
| 236 | -log "Download pretrained model and test-data from $repo_url" | ||
| 237 | -GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url | ||
| 238 | -pushd $repo | ||
| 239 | -git lfs pull --include "*.onnx" | ||
| 240 | - | ||
| 241 | -# remove .git to save spaces | ||
| 242 | -rm -rf .git | ||
| 243 | -rm -v .gitattributes | ||
| 244 | -rm -rf test_wavs | ||
| 245 | -rm -v README.md | ||
| 246 | -rm -v export*.sh | ||
| 247 | -rm -v *state* | ||
| 248 | -rm -v encoder-epoch-99-avg-1.onnx | ||
| 249 | -rm -v decoder-epoch-99-avg-1.int8.onnx | ||
| 250 | -rm -v joiner-epoch-99-avg-1.int8.onnx | ||
| 251 | - | ||
| 252 | -popd | ||
| 253 | - | ||
| 254 | -mv -v $repo ./android/SherpaOnnx/app/src/main/assets/ | ||
| 255 | -tree ./android/SherpaOnnx/app/src/main/assets/ | ||
| 256 | -git checkout . | ||
| 257 | - | ||
| 258 | -pushd android/SherpaOnnx/app/src/main/java/com/k2fsa/sherpa/onnx | ||
| 259 | -sed -i.bak s/"type = 0"/"type = 8"/ ./MainActivity.kt | ||
| 260 | -git diff | ||
| 261 | -popd | ||
| 262 | - | ||
| 263 | -for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 264 | - log "------------------------------------------------------------" | ||
| 265 | - log "build apk for $arch" | ||
| 266 | - log "------------------------------------------------------------" | ||
| 267 | - src_arch=$arch | ||
| 268 | - if [ $arch == "armeabi-v7a" ]; then | ||
| 269 | - src_arch=armv7-eabi | ||
| 270 | - elif [ $arch == "x86_64" ]; then | ||
| 271 | - src_arch=x86-64 | ||
| 272 | - fi | ||
| 273 | - | ||
| 274 | - ls -lh ./build-android-$src_arch/install/lib/*.so | ||
| 275 | - | ||
| 276 | - cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx/app/src/main/jniLibs/$arch/ | ||
| 277 | - | ||
| 278 | - pushd ./android/SherpaOnnx | ||
| 279 | - ./gradlew build | ||
| 280 | - popd | ||
| 281 | - | ||
| 282 | - mv android/SherpaOnnx/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-bilingual-en-zh.apk | ||
| 283 | - ls -lh apks | ||
| 284 | - rm -v ./android/SherpaOnnx/app/src/main/jniLibs/$arch/*.so | ||
| 285 | -done | ||
| 286 | - | ||
| 287 | -git checkout . | ||
| 288 | - | ||
| 289 | -rm -rf ./android/SherpaOnnx/app/src/main/assets/$repo | ||
| 290 | - | ||
| 291 | -ls -lh apks/ |
scripts/apk/build-apk-asr-2pass.sh.in
0 → 100644
| 1 | +#!/usr/bin/env bash | ||
| 2 | +# | ||
| 3 | +# Auto generated! Please DO NOT EDIT! | ||
| 4 | + | ||
| 5 | +# Please set the environment variable ANDROID_NDK | ||
| 6 | +# before running this script | ||
| 7 | + | ||
| 8 | +# Inside the $ANDROID_NDK directory, you can find a binary ndk-build | ||
| 9 | +# and some other files like the file "build/cmake/android.toolchain.cmake" | ||
| 10 | + | ||
| 11 | +set -ex | ||
| 12 | + | ||
| 13 | +log() { | ||
| 14 | + # This function is from espnet | ||
| 15 | + local fname=${BASH_SOURCE[1]##*/} | ||
| 16 | + echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*" | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 20 | + | ||
| 21 | +log "Building streaming ASR two-pass APK for sherpa-onnx v${SHERPA_ONNX_VERSION}" | ||
| 22 | + | ||
| 23 | +export SHERPA_ONNX_ENABLE_TTS=OFF | ||
| 24 | + | ||
| 25 | +log "====================arm64-v8a=================" | ||
| 26 | +./build-android-arm64-v8a.sh | ||
| 27 | +log "====================armv7-eabi================" | ||
| 28 | +./build-android-armv7-eabi.sh | ||
| 29 | +log "====================x86-64====================" | ||
| 30 | +./build-android-x86-64.sh | ||
| 31 | +log "====================x86====================" | ||
| 32 | +./build-android-x86.sh | ||
| 33 | + | ||
| 34 | +mkdir -p apks | ||
| 35 | + | ||
| 36 | +{% for first, second in model_list %} | ||
| 37 | +pushd ./android/SherpaOnnx2Pass/app/src/main/assets/ | ||
| 38 | + | ||
| 39 | +model_name1={{ first.model_name }} | ||
| 40 | +model_name=$model_name1 | ||
| 41 | +type1={{ first.idx }} | ||
| 42 | +lang1={{ first.lang }} | ||
| 43 | +short_name1={{ first.short_name }} | ||
| 44 | + | ||
| 45 | +curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/${model_name1}.tar.bz2 | ||
| 46 | +tar xvf ${model_name1}.tar.bz2 | ||
| 47 | + | ||
| 48 | +{{ first.cmd }} | ||
| 49 | + | ||
| 50 | +rm -rf *.tar.bz2 | ||
| 51 | +ls -lh $model_name1 | ||
| 52 | + | ||
| 53 | +model_name2={{ second.model_name }} | ||
| 54 | +model_name=$model_name2 | ||
| 55 | +type2={{ second.idx }} | ||
| 56 | +lang2={{ second.lang }} | ||
| 57 | +short_name2={{ second.short_name }} | ||
| 58 | + | ||
| 59 | +curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/${model_name2}.tar.bz2 | ||
| 60 | +tar xvf ${model_name2}.tar.bz2 | ||
| 61 | + | ||
| 62 | +{{ second.cmd }} | ||
| 63 | + | ||
| 64 | +rm -rf *.tar.bz2 | ||
| 65 | +ls -lh $model_name2 | ||
| 66 | + | ||
| 67 | +popd | ||
| 68 | +# Now we are at the project root directory | ||
| 69 | + | ||
| 70 | +git checkout . | ||
| 71 | +pushd android/SherpaOnnx2Pass/app/src/main/java/com/k2fsa/sherpa/onnx | ||
| 72 | +sed -i.bak s/"firstType = 9/firstType = $type1/" ./MainActivity.kt | ||
| 73 | +sed -i.bak s/"secondType = 0/secondType = $type2/" ./MainActivity.kt | ||
| 74 | +git diff | ||
| 75 | +popd | ||
| 76 | + | ||
| 77 | +for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 78 | + log "------------------------------------------------------------" | ||
| 79 | + log "build ASR apk for $arch" | ||
| 80 | + log "------------------------------------------------------------" | ||
| 81 | + src_arch=$arch | ||
| 82 | + if [ $arch == "armeabi-v7a" ]; then | ||
| 83 | + src_arch=armv7-eabi | ||
| 84 | + elif [ $arch == "x86_64" ]; then | ||
| 85 | + src_arch=x86-64 | ||
| 86 | + fi | ||
| 87 | + | ||
| 88 | + ls -lh ./build-android-$src_arch/install/lib/*.so | ||
| 89 | + | ||
| 90 | + cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/ | ||
| 91 | + | ||
| 92 | + pushd ./android/SherpaOnnx2Pass | ||
| 93 | + sed -i.bak s/2048/9012/g ./gradle.properties | ||
| 94 | + git diff ./gradle.properties | ||
| 95 | + ./gradlew assembleRelease | ||
| 96 | + popd | ||
| 97 | + | ||
| 98 | + 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 | ||
| 99 | + ls -lh apks | ||
| 100 | + rm -v ./android/SherpaOnnx2Pass/app/src/main/jniLibs/$arch/*.so | ||
| 101 | +done | ||
| 102 | + | ||
| 103 | +rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$model_name1 | ||
| 104 | +rm -rf ./android/SherpaOnnx2Pass/app/src/main/assets/$model_name2 | ||
| 105 | +{% endfor %} | ||
| 106 | + | ||
| 107 | +git checkout . | ||
| 108 | + | ||
| 109 | +ls -lh apks/ |
| @@ -18,6 +18,8 @@ SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " | @@ -18,6 +18,8 @@ SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " | ||
| 18 | 18 | ||
| 19 | log "Building keyword spotting APK for sherpa-onnx v${SHERPA_ONNX_VERSION}" | 19 | log "Building keyword spotting APK for sherpa-onnx v${SHERPA_ONNX_VERSION}" |
| 20 | 20 | ||
| 21 | +export SHERPA_ONNX_ENABLE_TTS=OFF | ||
| 22 | + | ||
| 21 | log "====================arm64-v8a=================" | 23 | log "====================arm64-v8a=================" |
| 22 | ./build-android-arm64-v8a.sh | 24 | ./build-android-arm64-v8a.sh |
| 23 | log "====================armv7-eabi================" | 25 | log "====================armv7-eabi================" |
| @@ -34,14 +36,17 @@ repo=sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01 | @@ -34,14 +36,17 @@ repo=sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01 | ||
| 34 | 36 | ||
| 35 | if [ ! -d ./android/SherpaOnnxKws/app/src/main/assets/$repo ]; then | 37 | if [ ! -d ./android/SherpaOnnxKws/app/src/main/assets/$repo ]; then |
| 36 | 38 | ||
| 37 | - 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 | 39 | + 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 |
| 38 | log "Start testing ${repo_url}" | 40 | log "Start testing ${repo_url}" |
| 39 | 41 | ||
| 40 | - log "Download pretrained model and test-data from $repo_url" | ||
| 41 | - wget -c -qq $repo_url | ||
| 42 | - tar jxvf ${repo}.tar.bz | 42 | + log "Download pretrained model from $repo_url" |
| 43 | + curl -SL -O $repo_url | ||
| 44 | + tar jxvf ${repo}.tar.bz2 | ||
| 45 | + rm ${repo}.tar.bz2 | ||
| 43 | 46 | ||
| 44 | pushd $repo | 47 | pushd $repo |
| 48 | + rm configuration.json | ||
| 49 | + rm keywords_raw.txt | ||
| 45 | rm *.int8.onnx | 50 | rm *.int8.onnx |
| 46 | rm README.md | 51 | rm README.md |
| 47 | rm -rfv test_wavs | 52 | rm -rfv test_wavs |
| @@ -69,10 +74,13 @@ for arch in arm64-v8a armeabi-v7a x86_64 x86; do | @@ -69,10 +74,13 @@ for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 69 | cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/ | 74 | cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/ |
| 70 | 75 | ||
| 71 | pushd ./android/SherpaOnnxKws | 76 | pushd ./android/SherpaOnnxKws |
| 72 | - ./gradlew build | 77 | + sed -i.bak s/2048/9012/g ./gradle.properties |
| 78 | + git diff ./gradle.properties | ||
| 79 | + ./gradlew assembleRelease | ||
| 73 | popd | 80 | popd |
| 74 | 81 | ||
| 75 | - mv android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-kws-wenetspeech-zh-${SHERPA_ONNX_VERSION}-$arch.apk | 82 | + mv android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-zh-wenetspeech-zipformer.apk |
| 83 | + | ||
| 76 | ls -lh apks | 84 | ls -lh apks |
| 77 | rm -v ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/*.so | 85 | rm -v ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/*.so |
| 78 | done | 86 | done |
| @@ -85,13 +93,16 @@ rm -rf ./android/SherpaOnnxKws/app/src/main/assets/$repo | @@ -85,13 +93,16 @@ rm -rf ./android/SherpaOnnxKws/app/src/main/assets/$repo | ||
| 85 | repo=sherpa-onnx-kws-zipformer-gigaspeech-3.3M-2024-01-01 | 93 | repo=sherpa-onnx-kws-zipformer-gigaspeech-3.3M-2024-01-01 |
| 86 | 94 | ||
| 87 | if [ ! -d ./android/SherpaOnnxKws/app/src/main/assets/$repo ]; then | 95 | if [ ! -d ./android/SherpaOnnxKws/app/src/main/assets/$repo ]; then |
| 88 | - 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 | 96 | + 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 |
| 89 | log "Start testing ${repo_url}" | 97 | log "Start testing ${repo_url}" |
| 90 | - log "Download pretrained model and test-data from $repo_url" | ||
| 91 | - wget -qq $repo_url | ||
| 92 | - tar jxvf ${repo}.tar.bz | 98 | + log "Download pretrained model from $repo_url" |
| 99 | + curl -SL -O $repo_url | ||
| 100 | + tar jxvf ${repo}.tar.bz2 | ||
| 101 | + rm ${repo}.tar.bz2 | ||
| 93 | 102 | ||
| 94 | pushd $repo | 103 | pushd $repo |
| 104 | + rm bpe.model | ||
| 105 | + rm keywords_raw.txt | ||
| 95 | rm *.int8.onnx | 106 | rm *.int8.onnx |
| 96 | rm README.md | 107 | rm README.md |
| 97 | rm -rfv test_wavs | 108 | rm -rfv test_wavs |
| @@ -124,10 +135,12 @@ for arch in arm64-v8a armeabi-v7a x86_64 x86; do | @@ -124,10 +135,12 @@ for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 124 | cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/ | 135 | cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/ |
| 125 | 136 | ||
| 126 | pushd ./android/SherpaOnnxKws | 137 | pushd ./android/SherpaOnnxKws |
| 127 | - ./gradlew build | 138 | + sed -i.bak s/2048/9012/g ./gradle.properties |
| 139 | + git diff ./gradle.properties | ||
| 140 | + ./gradlew assembleRelease | ||
| 128 | popd | 141 | popd |
| 129 | 142 | ||
| 130 | - mv android/SherpaOnnxKws/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-kws-gigaspeech-en-${SHERPA_ONNX_VERSION}-$arch.apk | 143 | + mv android/SherpaOnnxKws/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-kws-en-gigaspeech-zipformer.apk |
| 131 | ls -lh apks | 144 | ls -lh apks |
| 132 | rm -v ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/*.so | 145 | rm -v ./android/SherpaOnnxKws/app/src/main/jniLibs/$arch/*.so |
| 133 | done | 146 | done |
scripts/apk/build-apk-vad-asr.sh.in
0 → 100644
| 1 | +#!/usr/bin/env bash | ||
| 2 | +# | ||
| 3 | +# Auto generated! Please DO NOT EDIT! | ||
| 4 | + | ||
| 5 | +# Please set the environment variable ANDROID_NDK | ||
| 6 | +# before running this script | ||
| 7 | + | ||
| 8 | +# Inside the $ANDROID_NDK directory, you can find a binary ndk-build | ||
| 9 | +# and some other files like the file "build/cmake/android.toolchain.cmake" | ||
| 10 | + | ||
| 11 | +set -ex | ||
| 12 | + | ||
| 13 | +log() { | ||
| 14 | + # This function is from espnet | ||
| 15 | + local fname=${BASH_SOURCE[1]##*/} | ||
| 16 | + echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*" | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) | ||
| 20 | + | ||
| 21 | +log "Building streaming VAD + ASR APK for sherpa-onnx v${SHERPA_ONNX_VERSION}" | ||
| 22 | + | ||
| 23 | +export SHERPA_ONNX_ENABLE_TTS=OFF | ||
| 24 | + | ||
| 25 | +log "====================arm64-v8a=================" | ||
| 26 | +./build-android-arm64-v8a.sh | ||
| 27 | +log "====================armv7-eabi================" | ||
| 28 | +./build-android-armv7-eabi.sh | ||
| 29 | +log "====================x86-64====================" | ||
| 30 | +./build-android-x86-64.sh | ||
| 31 | +log "====================x86====================" | ||
| 32 | +./build-android-x86.sh | ||
| 33 | + | ||
| 34 | +mkdir -p apks | ||
| 35 | + | ||
| 36 | +{% for model in model_list %} | ||
| 37 | +pushd ./android/SherpaOnnxVadAsr/app/src/main/assets/ | ||
| 38 | +model_name={{ model.model_name }} | ||
| 39 | +type={{ model.idx }} | ||
| 40 | +lang={{ model.lang }} | ||
| 41 | +short_name={{ model.short_name }} | ||
| 42 | + | ||
| 43 | +curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/${model_name}.tar.bz2 | ||
| 44 | +tar xvf ${model_name}.tar.bz2 | ||
| 45 | + | ||
| 46 | +{{ model.cmd }} | ||
| 47 | + | ||
| 48 | +rm -rf *.tar.bz2 | ||
| 49 | +ls -lh $model_name | ||
| 50 | + | ||
| 51 | +curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/silero_vad.onnx | ||
| 52 | + | ||
| 53 | +popd | ||
| 54 | +# Now we are at the project root directory | ||
| 55 | + | ||
| 56 | +git checkout . | ||
| 57 | +pushd android/SherpaOnnxVadAsr/app/src/main/java/com/k2fsa/sherpa/onnx | ||
| 58 | +sed -i.bak s/"asrModelType = 0/asrModelType = $type/" ./MainActivity.kt | ||
| 59 | +git diff | ||
| 60 | +popd | ||
| 61 | + | ||
| 62 | +for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 63 | + log "------------------------------------------------------------" | ||
| 64 | + log "build ASR apk for $arch" | ||
| 65 | + log "------------------------------------------------------------" | ||
| 66 | + src_arch=$arch | ||
| 67 | + if [ $arch == "armeabi-v7a" ]; then | ||
| 68 | + src_arch=armv7-eabi | ||
| 69 | + elif [ $arch == "x86_64" ]; then | ||
| 70 | + src_arch=x86-64 | ||
| 71 | + fi | ||
| 72 | + | ||
| 73 | + ls -lh ./build-android-$src_arch/install/lib/*.so | ||
| 74 | + | ||
| 75 | + cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxVadAsr/app/src/main/jniLibs/$arch/ | ||
| 76 | + | ||
| 77 | + pushd ./android/SherpaOnnxVadAsr | ||
| 78 | + sed -i.bak s/2048/9012/g ./gradle.properties | ||
| 79 | + git diff ./gradle.properties | ||
| 80 | + ./gradlew assembleRelease | ||
| 81 | + popd | ||
| 82 | + | ||
| 83 | + 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 | ||
| 84 | + ls -lh apks | ||
| 85 | + rm -v ./android/SherpaOnnxVadAsr/app/src/main/jniLibs/$arch/*.so | ||
| 86 | +done | ||
| 87 | + | ||
| 88 | +rm -rf ./android/SherpaOnnxVadAsr/app/src/main/assets/$model_name | ||
| 89 | +{% endfor %} | ||
| 90 | + | ||
| 91 | +git checkout . | ||
| 92 | + | ||
| 93 | +ls -lh apks/ |
| @@ -18,6 +18,8 @@ SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " | @@ -18,6 +18,8 @@ SHERPA_ONNX_VERSION=$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " | ||
| 18 | 18 | ||
| 19 | log "Building APK for sherpa-onnx v${SHERPA_ONNX_VERSION}" | 19 | log "Building APK for sherpa-onnx v${SHERPA_ONNX_VERSION}" |
| 20 | 20 | ||
| 21 | +export SHERPA_ONNX_ENABLE_TTS=OFF | ||
| 22 | + | ||
| 21 | log "====================arm64-v8a=================" | 23 | log "====================arm64-v8a=================" |
| 22 | ./build-android-arm64-v8a.sh | 24 | ./build-android-arm64-v8a.sh |
| 23 | log "====================armv7-eabi================" | 25 | log "====================armv7-eabi================" |
| @@ -53,10 +55,12 @@ for arch in arm64-v8a armeabi-v7a x86_64 x86; do | @@ -53,10 +55,12 @@ for arch in arm64-v8a armeabi-v7a x86_64 x86; do | ||
| 53 | cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxVad/app/src/main/jniLibs/$arch/ | 55 | cp -v ./build-android-$src_arch/install/lib/*.so ./android/SherpaOnnxVad/app/src/main/jniLibs/$arch/ |
| 54 | 56 | ||
| 55 | pushd ./android/SherpaOnnxVad | 57 | pushd ./android/SherpaOnnxVad |
| 56 | - ./gradlew build | 58 | + sed -i.bak s/2048/9012/g ./gradle.properties |
| 59 | + git diff ./gradle.properties | ||
| 60 | + ./gradlew assembleRelease | ||
| 57 | popd | 61 | popd |
| 58 | 62 | ||
| 59 | - mv android/SherpaOnnxVad/app/build/outputs/apk/debug/app-debug.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-silero-vad.apk | 63 | + mv android/SherpaOnnxVad/app/build/outputs/apk/release/app-release-unsigned.apk ./apks/sherpa-onnx-${SHERPA_ONNX_VERSION}-$arch-silero_vad.apk |
| 60 | ls -lh apks | 64 | ls -lh apks |
| 61 | rm -v ./android/SherpaOnnxVad/app/src/main/jniLibs/$arch/*.so | 65 | rm -v ./android/SherpaOnnxVad/app/src/main/jniLibs/$arch/*.so |
| 62 | done | 66 | done |
scripts/apk/generate-asr-2pass-apk-script.py
0 → 100755
| 1 | +#!/usr/bin/env python3 | ||
| 2 | + | ||
| 3 | +import argparse | ||
| 4 | +from dataclasses import dataclass | ||
| 5 | +from typing import List, Optional | ||
| 6 | + | ||
| 7 | +import jinja2 | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +def get_args(): | ||
| 11 | + parser = argparse.ArgumentParser() | ||
| 12 | + parser.add_argument( | ||
| 13 | + "--total", | ||
| 14 | + type=int, | ||
| 15 | + default=1, | ||
| 16 | + help="Number of runners", | ||
| 17 | + ) | ||
| 18 | + parser.add_argument( | ||
| 19 | + "--index", | ||
| 20 | + type=int, | ||
| 21 | + default=0, | ||
| 22 | + help="Index of the current runner", | ||
| 23 | + ) | ||
| 24 | + return parser.parse_args() | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +@dataclass | ||
| 28 | +class Model: | ||
| 29 | + # We will download | ||
| 30 | + # https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/{model_name}.tar.bz2 | ||
| 31 | + model_name: str | ||
| 32 | + | ||
| 33 | + # The type of the model, e..g, 0, 1, 2. It is hardcoded in the kotlin code | ||
| 34 | + idx: int | ||
| 35 | + | ||
| 36 | + # e.g., zh, en, zh_en | ||
| 37 | + lang: str | ||
| 38 | + | ||
| 39 | + # e.g., whisper, paraformer, zipformer | ||
| 40 | + short_name: str = "" | ||
| 41 | + | ||
| 42 | + # cmd is used to remove extra file from the model directory | ||
| 43 | + cmd: str = "" | ||
| 44 | + | ||
| 45 | + | ||
| 46 | +def get_2nd_models(): | ||
| 47 | + models = [ | ||
| 48 | + Model( | ||
| 49 | + model_name="sherpa-onnx-whisper-tiny.en", | ||
| 50 | + idx=2, | ||
| 51 | + lang="en", | ||
| 52 | + short_name="whisper_tiny", | ||
| 53 | + cmd=""" | ||
| 54 | + pushd $model_name | ||
| 55 | + rm -v tiny.en-encoder.onnx | ||
| 56 | + rm -v tiny.en-decoder.onnx | ||
| 57 | + rm -rf test_wavs | ||
| 58 | + rm -v *.py | ||
| 59 | + rm -v requirements.txt | ||
| 60 | + rm -v .gitignore | ||
| 61 | + rm -v README.md | ||
| 62 | + | ||
| 63 | + ls -lh | ||
| 64 | + | ||
| 65 | + popd | ||
| 66 | + """, | ||
| 67 | + ), | ||
| 68 | + Model( | ||
| 69 | + model_name="sherpa-onnx-paraformer-zh-2023-03-28", | ||
| 70 | + idx=0, | ||
| 71 | + lang="zh", | ||
| 72 | + short_name="paraformer", | ||
| 73 | + cmd=""" | ||
| 74 | + pushd $model_name | ||
| 75 | + | ||
| 76 | + rm -v README.md | ||
| 77 | + rm -rfv test_wavs | ||
| 78 | + rm model.onnx | ||
| 79 | + | ||
| 80 | + ls -lh | ||
| 81 | + | ||
| 82 | + popd | ||
| 83 | + """, | ||
| 84 | + ), | ||
| 85 | + Model( | ||
| 86 | + model_name="icefall-asr-zipformer-wenetspeech-20230615", | ||
| 87 | + idx=4, | ||
| 88 | + lang="zh", | ||
| 89 | + short_name="zipformer", | ||
| 90 | + cmd=""" | ||
| 91 | + pushd $model_name | ||
| 92 | + | ||
| 93 | + rm -rfv test_wavs | ||
| 94 | + rm -v README.md | ||
| 95 | + mv -v data/lang_char/tokens.txt ./ | ||
| 96 | + rm -rfv data/lang_char | ||
| 97 | + | ||
| 98 | + mv -v exp/encoder-epoch-12-avg-4.int8.onnx ./ | ||
| 99 | + mv -v exp/decoder-epoch-12-avg-4.onnx ./ | ||
| 100 | + mv -v exp/joiner-epoch-12-avg-4.int8.onnx ./ | ||
| 101 | + rm -rfv exp | ||
| 102 | + | ||
| 103 | + ls -lh | ||
| 104 | + | ||
| 105 | + popd | ||
| 106 | + """, | ||
| 107 | + ), | ||
| 108 | + ] | ||
| 109 | + return models | ||
| 110 | + | ||
| 111 | + | ||
| 112 | +def get_1st_models(): | ||
| 113 | + # See as ./generate-asr-apk-script.py | ||
| 114 | + models = [ | ||
| 115 | + Model( | ||
| 116 | + model_name="sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20", | ||
| 117 | + idx=8, | ||
| 118 | + lang="bilingual_zh_en", | ||
| 119 | + short_name="zipformer", | ||
| 120 | + cmd=""" | ||
| 121 | + pushd $model_name | ||
| 122 | + rm -v decoder-epoch-99-avg-1.int8.onnx | ||
| 123 | + rm -v encoder-epoch-99-avg-1.onnx | ||
| 124 | + rm -v joiner-epoch-99-avg-1.onnx | ||
| 125 | + | ||
| 126 | + rm -v *.sh | ||
| 127 | + rm -v bpe.model | ||
| 128 | + rm -v README.md | ||
| 129 | + rm -v .gitattributes | ||
| 130 | + rm -v *state* | ||
| 131 | + rm -rfv test_wavs | ||
| 132 | + | ||
| 133 | + ls -lh | ||
| 134 | + | ||
| 135 | + popd | ||
| 136 | + """, | ||
| 137 | + ), | ||
| 138 | + Model( | ||
| 139 | + model_name="sherpa-onnx-streaming-zipformer-en-2023-06-26", | ||
| 140 | + idx=6, | ||
| 141 | + lang="en", | ||
| 142 | + short_name="zipformer2", | ||
| 143 | + cmd=""" | ||
| 144 | + pushd $model_name | ||
| 145 | + rm -v encoder-epoch-99-avg-1-chunk-16-left-128.onnx | ||
| 146 | + rm -v decoder-epoch-99-avg-1-chunk-16-left-128.int8.onnx | ||
| 147 | + rm -v joiner-epoch-99-avg-1-chunk-16-left-128.int8.onnx | ||
| 148 | + | ||
| 149 | + rm -v README.md | ||
| 150 | + rm -v bpe.model | ||
| 151 | + rm -rfv test_wavs | ||
| 152 | + | ||
| 153 | + ls -lh | ||
| 154 | + | ||
| 155 | + popd | ||
| 156 | + """, | ||
| 157 | + ), | ||
| 158 | + Model( | ||
| 159 | + model_name="icefall-asr-zipformer-streaming-wenetspeech-20230615", | ||
| 160 | + idx=3, | ||
| 161 | + lang="zh", | ||
| 162 | + short_name="zipformer2", | ||
| 163 | + cmd=""" | ||
| 164 | + pushd $model_name | ||
| 165 | + rm -v exp/encoder-epoch-12-avg-4-chunk-16-left-128.onnx | ||
| 166 | + rm -v exp/decoder-epoch-12-avg-4-chunk-16-left-128.int8.onnx | ||
| 167 | + rm -v exp/joiner-epoch-12-avg-4-chunk-16-left-128.int8.onnx | ||
| 168 | + | ||
| 169 | + rm -v data/lang_char/lexicon.txt | ||
| 170 | + rm -v data/lang_char/words.txt | ||
| 171 | + rm -rfv test_wavs | ||
| 172 | + rm -v README.md | ||
| 173 | + | ||
| 174 | + ls -lh exp/ | ||
| 175 | + ls -lh data/lang_char | ||
| 176 | + | ||
| 177 | + popd | ||
| 178 | + """, | ||
| 179 | + ), | ||
| 180 | + Model( | ||
| 181 | + model_name="sherpa-onnx-streaming-zipformer-fr-2023-04-14", | ||
| 182 | + idx=7, | ||
| 183 | + lang="fr", | ||
| 184 | + short_name="zipformer", | ||
| 185 | + cmd=""" | ||
| 186 | + pushd $model_name | ||
| 187 | + rm -v encoder-epoch-29-avg-9-with-averaged-model.onnx | ||
| 188 | + rm -v decoder-epoch-29-avg-9-with-averaged-model.int8.onnx | ||
| 189 | + rm -v joiner-epoch-29-avg-9-with-averaged-model.int8.onnx | ||
| 190 | + | ||
| 191 | + rm -v *.sh | ||
| 192 | + rm -rf test_wavs | ||
| 193 | + rm README.md | ||
| 194 | + | ||
| 195 | + ls -lh | ||
| 196 | + | ||
| 197 | + popd | ||
| 198 | + """, | ||
| 199 | + ), | ||
| 200 | + Model( | ||
| 201 | + model_name="sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23", | ||
| 202 | + idx=9, | ||
| 203 | + lang="zh", | ||
| 204 | + short_name="small_zipformer", | ||
| 205 | + cmd=""" | ||
| 206 | + pushd $model_name | ||
| 207 | + rm -v encoder-epoch-99-avg-1.onnx | ||
| 208 | + rm -v decoder-epoch-99-avg-1.int8.onnx | ||
| 209 | + rm -v joiner-epoch-99-avg-1.onnx | ||
| 210 | + | ||
| 211 | + rm -v *.sh | ||
| 212 | + rm -rf test_wavs | ||
| 213 | + rm README.md | ||
| 214 | + | ||
| 215 | + ls -lh | ||
| 216 | + | ||
| 217 | + popd | ||
| 218 | + """, | ||
| 219 | + ), | ||
| 220 | + Model( | ||
| 221 | + model_name="sherpa-onnx-streaming-zipformer-en-20M-2023-02-17", | ||
| 222 | + idx=10, | ||
| 223 | + lang="en", | ||
| 224 | + short_name="small_zipformer", | ||
| 225 | + cmd=""" | ||
| 226 | + pushd $model_name | ||
| 227 | + rm -v encoder-epoch-99-avg-1.onnx | ||
| 228 | + rm -v decoder-epoch-99-avg-1.int8.onnx | ||
| 229 | + rm -v joiner-epoch-99-avg-1.onnx | ||
| 230 | + | ||
| 231 | + rm -v *.sh | ||
| 232 | + rm -rf test_wavs | ||
| 233 | + rm README.md | ||
| 234 | + | ||
| 235 | + ls -lh | ||
| 236 | + | ||
| 237 | + popd | ||
| 238 | + """, | ||
| 239 | + ), | ||
| 240 | + ] | ||
| 241 | + | ||
| 242 | + return models | ||
| 243 | + | ||
| 244 | + | ||
| 245 | +def get_models(): | ||
| 246 | + first = get_1st_models() | ||
| 247 | + second = get_2nd_models() | ||
| 248 | + | ||
| 249 | + combinations = [ | ||
| 250 | + ( | ||
| 251 | + "sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23", | ||
| 252 | + "sherpa-onnx-paraformer-zh-2023-03-28", | ||
| 253 | + ), | ||
| 254 | + ( | ||
| 255 | + "sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23", | ||
| 256 | + "icefall-asr-zipformer-wenetspeech-20230615", | ||
| 257 | + ), | ||
| 258 | + ( | ||
| 259 | + "sherpa-onnx-streaming-zipformer-en-20M-2023-02-17", | ||
| 260 | + "sherpa-onnx-whisper-tiny.en", | ||
| 261 | + ), | ||
| 262 | + ] | ||
| 263 | + models = [] | ||
| 264 | + for f, s in combinations: | ||
| 265 | + t = [] | ||
| 266 | + for m in first: | ||
| 267 | + if m.model_name == f: | ||
| 268 | + t.append(m) | ||
| 269 | + break | ||
| 270 | + assert len(t) == 1, (f, s, first, second) | ||
| 271 | + | ||
| 272 | + for m in second: | ||
| 273 | + if m.model_name == s: | ||
| 274 | + t.append(m) | ||
| 275 | + break | ||
| 276 | + assert len(t) == 2, (f, s, first, second) | ||
| 277 | + | ||
| 278 | + models.append(t) | ||
| 279 | + | ||
| 280 | + return models | ||
| 281 | + | ||
| 282 | + | ||
| 283 | +def main(): | ||
| 284 | + args = get_args() | ||
| 285 | + index = args.index | ||
| 286 | + total = args.total | ||
| 287 | + assert 0 <= index < total, (index, total) | ||
| 288 | + | ||
| 289 | + all_model_list = get_models() | ||
| 290 | + | ||
| 291 | + num_models = len(all_model_list) | ||
| 292 | + | ||
| 293 | + num_per_runner = num_models // total | ||
| 294 | + if num_per_runner <= 0: | ||
| 295 | + raise ValueError(f"num_models: {num_models}, num_runners: {total}") | ||
| 296 | + | ||
| 297 | + start = index * num_per_runner | ||
| 298 | + end = start + num_per_runner | ||
| 299 | + | ||
| 300 | + remaining = num_models - args.total * num_per_runner | ||
| 301 | + | ||
| 302 | + print(f"{index}/{total}: {start}-{end}/{num_models}") | ||
| 303 | + | ||
| 304 | + d = dict() | ||
| 305 | + d["model_list"] = all_model_list[start:end] | ||
| 306 | + if index < remaining: | ||
| 307 | + s = args.total * num_per_runner + index | ||
| 308 | + d["model_list"].append(all_model_list[s]) | ||
| 309 | + print(f"{s}/{num_models}") | ||
| 310 | + | ||
| 311 | + filename_list = [ | ||
| 312 | + "./build-apk-asr-2pass.sh", | ||
| 313 | + ] | ||
| 314 | + for filename in filename_list: | ||
| 315 | + environment = jinja2.Environment() | ||
| 316 | + with open(f"{filename}.in") as f: | ||
| 317 | + s = f.read() | ||
| 318 | + template = environment.from_string(s) | ||
| 319 | + | ||
| 320 | + s = template.render(**d) | ||
| 321 | + with open(filename, "w") as f: | ||
| 322 | + print(s, file=f) | ||
| 323 | + | ||
| 324 | + | ||
| 325 | +if __name__ == "__main__": | ||
| 326 | + main() |
| @@ -57,6 +57,8 @@ def get_models(): | @@ -57,6 +57,8 @@ def get_models(): | ||
| 57 | rm -v joiner-epoch-99-avg-1.onnx | 57 | rm -v joiner-epoch-99-avg-1.onnx |
| 58 | 58 | ||
| 59 | rm -v *.sh | 59 | rm -v *.sh |
| 60 | + rm -v bpe.model | ||
| 61 | + rm -v README.md | ||
| 60 | rm -v .gitattributes | 62 | rm -v .gitattributes |
| 61 | rm -v *state* | 63 | rm -v *state* |
| 62 | rm -rfv test_wavs | 64 | rm -rfv test_wavs |
| @@ -66,6 +68,108 @@ def get_models(): | @@ -66,6 +68,108 @@ def get_models(): | ||
| 66 | popd | 68 | popd |
| 67 | """, | 69 | """, |
| 68 | ), | 70 | ), |
| 71 | + Model( | ||
| 72 | + model_name="sherpa-onnx-streaming-zipformer-en-2023-06-26", | ||
| 73 | + idx=6, | ||
| 74 | + lang="en", | ||
| 75 | + short_name="zipformer2", | ||
| 76 | + cmd=""" | ||
| 77 | + pushd $model_name | ||
| 78 | + rm -v encoder-epoch-99-avg-1-chunk-16-left-128.onnx | ||
| 79 | + rm -v decoder-epoch-99-avg-1-chunk-16-left-128.int8.onnx | ||
| 80 | + rm -v joiner-epoch-99-avg-1-chunk-16-left-128.int8.onnx | ||
| 81 | + | ||
| 82 | + rm -v README.md | ||
| 83 | + rm -v bpe.model | ||
| 84 | + rm -rfv test_wavs | ||
| 85 | + | ||
| 86 | + ls -lh | ||
| 87 | + | ||
| 88 | + popd | ||
| 89 | + """, | ||
| 90 | + ), | ||
| 91 | + Model( | ||
| 92 | + model_name="icefall-asr-zipformer-streaming-wenetspeech-20230615", | ||
| 93 | + idx=3, | ||
| 94 | + lang="zh", | ||
| 95 | + short_name="zipformer2", | ||
| 96 | + cmd=""" | ||
| 97 | + pushd $model_name | ||
| 98 | + rm -v exp/encoder-epoch-12-avg-4-chunk-16-left-128.onnx | ||
| 99 | + rm -v exp/decoder-epoch-12-avg-4-chunk-16-left-128.int8.onnx | ||
| 100 | + rm -v exp/joiner-epoch-12-avg-4-chunk-16-left-128.int8.onnx | ||
| 101 | + | ||
| 102 | + rm -v data/lang_char/lexicon.txt | ||
| 103 | + rm -v data/lang_char/words.txt | ||
| 104 | + rm -rfv test_wavs | ||
| 105 | + rm -v README.md | ||
| 106 | + | ||
| 107 | + ls -lh exp/ | ||
| 108 | + ls -lh data/lang_char | ||
| 109 | + | ||
| 110 | + popd | ||
| 111 | + """, | ||
| 112 | + ), | ||
| 113 | + Model( | ||
| 114 | + model_name="sherpa-onnx-streaming-zipformer-fr-2023-04-14", | ||
| 115 | + idx=7, | ||
| 116 | + lang="fr", | ||
| 117 | + short_name="zipformer", | ||
| 118 | + cmd=""" | ||
| 119 | + pushd $model_name | ||
| 120 | + rm -v encoder-epoch-29-avg-9-with-averaged-model.onnx | ||
| 121 | + rm -v decoder-epoch-29-avg-9-with-averaged-model.int8.onnx | ||
| 122 | + rm -v joiner-epoch-29-avg-9-with-averaged-model.int8.onnx | ||
| 123 | + | ||
| 124 | + rm -v *.sh | ||
| 125 | + rm -rf test_wavs | ||
| 126 | + rm README.md | ||
| 127 | + | ||
| 128 | + ls -lh | ||
| 129 | + | ||
| 130 | + popd | ||
| 131 | + """, | ||
| 132 | + ), | ||
| 133 | + Model( | ||
| 134 | + model_name="sherpa-onnx-streaming-zipformer-zh-14M-2023-02-23", | ||
| 135 | + idx=9, | ||
| 136 | + lang="zh", | ||
| 137 | + short_name="small_zipformer", | ||
| 138 | + cmd=""" | ||
| 139 | + pushd $model_name | ||
| 140 | + rm -v encoder-epoch-99-avg-1.onnx | ||
| 141 | + rm -v decoder-epoch-99-avg-1.int8.onnx | ||
| 142 | + rm -v joiner-epoch-99-avg-1.onnx | ||
| 143 | + | ||
| 144 | + rm -v *.sh | ||
| 145 | + rm -rf test_wavs | ||
| 146 | + rm README.md | ||
| 147 | + | ||
| 148 | + ls -lh | ||
| 149 | + | ||
| 150 | + popd | ||
| 151 | + """, | ||
| 152 | + ), | ||
| 153 | + Model( | ||
| 154 | + model_name="sherpa-onnx-streaming-zipformer-en-20M-2023-02-17", | ||
| 155 | + idx=10, | ||
| 156 | + lang="en", | ||
| 157 | + short_name="small_zipformer", | ||
| 158 | + cmd=""" | ||
| 159 | + pushd $model_name | ||
| 160 | + rm -v encoder-epoch-99-avg-1.onnx | ||
| 161 | + rm -v decoder-epoch-99-avg-1.int8.onnx | ||
| 162 | + rm -v joiner-epoch-99-avg-1.onnx | ||
| 163 | + | ||
| 164 | + rm -v *.sh | ||
| 165 | + rm -rf test_wavs | ||
| 166 | + rm README.md | ||
| 167 | + | ||
| 168 | + ls -lh | ||
| 169 | + | ||
| 170 | + popd | ||
| 171 | + """, | ||
| 172 | + ), | ||
| 69 | ] | 173 | ] |
| 70 | 174 | ||
| 71 | return models | 175 | return models |
scripts/apk/generate-vad-asr-apk-script.py
0 → 100755
| 1 | +#!/usr/bin/env python3 | ||
| 2 | + | ||
| 3 | +import argparse | ||
| 4 | +from dataclasses import dataclass | ||
| 5 | +from typing import List, Optional | ||
| 6 | + | ||
| 7 | +import jinja2 | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +def get_args(): | ||
| 11 | + parser = argparse.ArgumentParser() | ||
| 12 | + parser.add_argument( | ||
| 13 | + "--total", | ||
| 14 | + type=int, | ||
| 15 | + default=1, | ||
| 16 | + help="Number of runners", | ||
| 17 | + ) | ||
| 18 | + parser.add_argument( | ||
| 19 | + "--index", | ||
| 20 | + type=int, | ||
| 21 | + default=0, | ||
| 22 | + help="Index of the current runner", | ||
| 23 | + ) | ||
| 24 | + return parser.parse_args() | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +@dataclass | ||
| 28 | +class Model: | ||
| 29 | + # We will download | ||
| 30 | + # https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/{model_name}.tar.bz2 | ||
| 31 | + model_name: str | ||
| 32 | + | ||
| 33 | + # The type of the model, e..g, 0, 1, 2. It is hardcoded in the kotlin code | ||
| 34 | + idx: int | ||
| 35 | + | ||
| 36 | + # e.g., zh, en, zh_en | ||
| 37 | + lang: str | ||
| 38 | + | ||
| 39 | + # e.g., whisper, paraformer, zipformer | ||
| 40 | + short_name: str = "" | ||
| 41 | + | ||
| 42 | + # cmd is used to remove extra file from the model directory | ||
| 43 | + cmd: str = "" | ||
| 44 | + | ||
| 45 | + | ||
| 46 | +# See get_2nd_models() in ./generate-asr-2pass-apk-script.py | ||
| 47 | +def get_models(): | ||
| 48 | + models = [ | ||
| 49 | + Model( | ||
| 50 | + model_name="sherpa-onnx-whisper-tiny.en", | ||
| 51 | + idx=2, | ||
| 52 | + lang="en", | ||
| 53 | + short_name="whisper_tiny", | ||
| 54 | + cmd=""" | ||
| 55 | + pushd $model_name | ||
| 56 | + rm -v tiny.en-encoder.onnx | ||
| 57 | + rm -v tiny.en-decoder.onnx | ||
| 58 | + rm -rf test_wavs | ||
| 59 | + rm -v *.py | ||
| 60 | + rm -v requirements.txt | ||
| 61 | + rm -v .gitignore | ||
| 62 | + rm -v README.md | ||
| 63 | + | ||
| 64 | + ls -lh | ||
| 65 | + | ||
| 66 | + popd | ||
| 67 | + """, | ||
| 68 | + ), | ||
| 69 | + Model( | ||
| 70 | + model_name="sherpa-onnx-paraformer-zh-2023-03-28", | ||
| 71 | + idx=0, | ||
| 72 | + lang="zh", | ||
| 73 | + short_name="paraformer", | ||
| 74 | + cmd=""" | ||
| 75 | + pushd $model_name | ||
| 76 | + | ||
| 77 | + rm -v README.md | ||
| 78 | + rm -rfv test_wavs | ||
| 79 | + rm model.onnx | ||
| 80 | + | ||
| 81 | + ls -lh | ||
| 82 | + | ||
| 83 | + popd | ||
| 84 | + """, | ||
| 85 | + ), | ||
| 86 | + Model( | ||
| 87 | + model_name="icefall-asr-zipformer-wenetspeech-20230615", | ||
| 88 | + idx=4, | ||
| 89 | + lang="zh", | ||
| 90 | + short_name="zipformer", | ||
| 91 | + cmd=""" | ||
| 92 | + pushd $model_name | ||
| 93 | + | ||
| 94 | + rm -rfv test_wavs | ||
| 95 | + rm -v README.md | ||
| 96 | + mv -v data/lang_char/tokens.txt ./ | ||
| 97 | + rm -rfv data/lang_char | ||
| 98 | + | ||
| 99 | + mv -v exp/encoder-epoch-12-avg-4.int8.onnx ./ | ||
| 100 | + mv -v exp/decoder-epoch-12-avg-4.onnx ./ | ||
| 101 | + mv -v exp/joiner-epoch-12-avg-4.int8.onnx ./ | ||
| 102 | + rm -rfv exp | ||
| 103 | + | ||
| 104 | + ls -lh | ||
| 105 | + | ||
| 106 | + popd | ||
| 107 | + """, | ||
| 108 | + ), | ||
| 109 | + ] | ||
| 110 | + return models | ||
| 111 | + | ||
| 112 | + | ||
| 113 | +def main(): | ||
| 114 | + args = get_args() | ||
| 115 | + index = args.index | ||
| 116 | + total = args.total | ||
| 117 | + assert 0 <= index < total, (index, total) | ||
| 118 | + | ||
| 119 | + all_model_list = get_models() | ||
| 120 | + | ||
| 121 | + num_models = len(all_model_list) | ||
| 122 | + | ||
| 123 | + num_per_runner = num_models // total | ||
| 124 | + if num_per_runner <= 0: | ||
| 125 | + raise ValueError(f"num_models: {num_models}, num_runners: {total}") | ||
| 126 | + | ||
| 127 | + start = index * num_per_runner | ||
| 128 | + end = start + num_per_runner | ||
| 129 | + | ||
| 130 | + remaining = num_models - args.total * num_per_runner | ||
| 131 | + | ||
| 132 | + print(f"{index}/{total}: {start}-{end}/{num_models}") | ||
| 133 | + | ||
| 134 | + d = dict() | ||
| 135 | + d["model_list"] = all_model_list[start:end] | ||
| 136 | + if index < remaining: | ||
| 137 | + s = args.total * num_per_runner + index | ||
| 138 | + d["model_list"].append(all_model_list[s]) | ||
| 139 | + print(f"{s}/{num_models}") | ||
| 140 | + | ||
| 141 | + filename_list = [ | ||
| 142 | + "./build-apk-vad-asr.sh", | ||
| 143 | + ] | ||
| 144 | + for filename in filename_list: | ||
| 145 | + environment = jinja2.Environment() | ||
| 146 | + with open(f"{filename}.in") as f: | ||
| 147 | + s = f.read() | ||
| 148 | + template = environment.from_string(s) | ||
| 149 | + | ||
| 150 | + s = template.render(**d) | ||
| 151 | + with open(filename, "w") as f: | ||
| 152 | + print(s, file=f) | ||
| 153 | + | ||
| 154 | + | ||
| 155 | +if __name__ == "__main__": | ||
| 156 | + main() |
-
请 注册 或 登录 后发表评论