Fangjun Kuang
Committed by GitHub

Add timestamps and tokens for .Net's online models. (#690)

@@ -179,7 +179,7 @@ jobs: @@ -179,7 +179,7 @@ jobs:
179 179
180 # https://huggingface.co/docs/hub/spaces-github-actions 180 # https://huggingface.co/docs/hub/spaces-github-actions
181 - name: Publish to huggingface 181 - name: Publish to huggingface
182 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' 182 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' && github.event_name == 'workflow_dispatch')
183 env: 183 env:
184 HF_TOKEN: ${{ secrets.HF_TOKEN }} 184 HF_TOKEN: ${{ secrets.HF_TOKEN }}
185 uses: nick-fields/retry@v3 185 uses: nick-fields/retry@v3
@@ -210,7 +210,7 @@ jobs: @@ -210,7 +210,7 @@ jobs:
210 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main 210 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main
211 211
212 - name: Release pre-compiled binaries and libs for aarch64 linux 212 - name: Release pre-compiled binaries and libs for aarch64 linux
213 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 213 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
214 uses: svenstaro/upload-release-action@v2 214 uses: svenstaro/upload-release-action@v2
215 with: 215 with:
216 file_glob: true 216 file_glob: true
@@ -170,7 +170,7 @@ jobs: @@ -170,7 +170,7 @@ jobs:
170 170
171 # https://huggingface.co/docs/hub/spaces-github-actions 171 # https://huggingface.co/docs/hub/spaces-github-actions
172 - name: Publish to huggingface 172 - name: Publish to huggingface
173 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' 173 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' && github.event_name == 'workflow_dispatch')
174 env: 174 env:
175 HF_TOKEN: ${{ secrets.HF_TOKEN }} 175 HF_TOKEN: ${{ secrets.HF_TOKEN }}
176 uses: nick-fields/retry@v3 176 uses: nick-fields/retry@v3
@@ -201,7 +201,7 @@ jobs: @@ -201,7 +201,7 @@ jobs:
201 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main 201 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main
202 202
203 - name: Release pre-compiled binaries and libs for aarch64 linux 203 - name: Release pre-compiled binaries and libs for aarch64 linux
204 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 204 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
205 uses: svenstaro/upload-release-action@v2 205 uses: svenstaro/upload-release-action@v2
206 with: 206 with:
207 file_glob: true 207 file_glob: true
@@ -101,7 +101,7 @@ jobs: @@ -101,7 +101,7 @@ jobs:
101 101
102 # https://huggingface.co/docs/hub/spaces-github-actions 102 # https://huggingface.co/docs/hub/spaces-github-actions
103 - name: Publish to huggingface 103 - name: Publish to huggingface
104 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 104 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' && github.event_name == 'workflow_dispatch')
105 env: 105 env:
106 HF_TOKEN: ${{ secrets.HF_TOKEN }} 106 HF_TOKEN: ${{ secrets.HF_TOKEN }}
107 run: | 107 run: |
@@ -193,7 +193,7 @@ jobs: @@ -193,7 +193,7 @@ jobs:
193 193
194 # https://huggingface.co/docs/hub/spaces-github-actions 194 # https://huggingface.co/docs/hub/spaces-github-actions
195 - name: Publish to huggingface 195 - name: Publish to huggingface
196 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' 196 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' && github.event_name == 'workflow_dispatch')
197 env: 197 env:
198 HF_TOKEN: ${{ secrets.HF_TOKEN }} 198 HF_TOKEN: ${{ secrets.HF_TOKEN }}
199 uses: nick-fields/retry@v3 199 uses: nick-fields/retry@v3
@@ -224,7 +224,7 @@ jobs: @@ -224,7 +224,7 @@ jobs:
224 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main 224 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main
225 225
226 - name: Release pre-compiled binaries and libs for arm linux gnueabihf ${{ matrix.lib_type }} 226 - name: Release pre-compiled binaries and libs for arm linux gnueabihf ${{ matrix.lib_type }}
227 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 227 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
228 uses: svenstaro/upload-release-action@v2 228 uses: svenstaro/upload-release-action@v2
229 with: 229 with:
230 file_glob: true 230 file_glob: true
@@ -24,7 +24,7 @@ jobs: @@ -24,7 +24,7 @@ jobs:
24 fetch-depth: 0 24 fetch-depth: 0
25 25
26 - name: Setup .NET 26 - name: Setup .NET
27 - uses: actions/setup-dotnet@v1 27 + uses: actions/setup-dotnet@v4
28 with: 28 with:
29 dotnet-version: | 29 dotnet-version: |
30 6.0.x 30 6.0.x
@@ -174,7 +174,7 @@ jobs: @@ -174,7 +174,7 @@ jobs:
174 tar cjvf ${dst}.tar.bz2 $dst 174 tar cjvf ${dst}.tar.bz2 $dst
175 175
176 - name: Release pre-compiled binaries and libs for linux x64 176 - name: Release pre-compiled binaries and libs for linux x64
177 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 177 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
178 uses: svenstaro/upload-release-action@v2 178 uses: svenstaro/upload-release-action@v2
179 with: 179 with:
180 file_glob: true 180 file_glob: true
@@ -210,7 +210,6 @@ jobs: @@ -210,7 +210,6 @@ jobs:
210 .github/scripts/test-online-transducer.sh 210 .github/scripts/test-online-transducer.sh
211 211
212 - name: Copy files 212 - name: Copy files
213 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')  
214 shell: bash 213 shell: bash
215 run: | 214 run: |
216 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) 215 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
@@ -227,7 +226,7 @@ jobs: @@ -227,7 +226,7 @@ jobs:
227 tar cjvf ${dst}.tar.bz2 $dst 226 tar cjvf ${dst}.tar.bz2 $dst
228 227
229 - name: Release pre-compiled binaries and libs for linux x64 228 - name: Release pre-compiled binaries and libs for linux x64
230 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-20.04' && matrix.gcc_version == '7' 229 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/') && matrix.os == 'ubuntu-20.04' && matrix.gcc_version == '7'
231 uses: svenstaro/upload-release-action@v2 230 uses: svenstaro/upload-release-action@v2
232 with: 231 with:
233 file_glob: true 232 file_glob: true
@@ -175,7 +175,6 @@ jobs: @@ -175,7 +175,6 @@ jobs:
175 .github/scripts/test-online-transducer.sh 175 .github/scripts/test-online-transducer.sh
176 176
177 - name: Copy files 177 - name: Copy files
178 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')  
179 shell: bash 178 shell: bash
180 run: | 179 run: |
181 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) 180 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
@@ -193,7 +192,7 @@ jobs: @@ -193,7 +192,7 @@ jobs:
193 tar cjvf ${dst}.tar.bz2 $dst 192 tar cjvf ${dst}.tar.bz2 $dst
194 193
195 - name: Release pre-compiled binaries and libs for macOS 194 - name: Release pre-compiled binaries and libs for macOS
196 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 195 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
197 uses: svenstaro/upload-release-action@v2 196 uses: svenstaro/upload-release-action@v2
198 with: 197 with:
199 file_glob: true 198 file_glob: true
@@ -124,7 +124,7 @@ jobs: @@ -124,7 +124,7 @@ jobs:
124 path: ./mfc-examples/${{ matrix.arch }}/Release/sherpa-onnx-non-streaming-asr-*.exe 124 path: ./mfc-examples/${{ matrix.arch }}/Release/sherpa-onnx-non-streaming-asr-*.exe
125 125
126 - name: Release pre-compiled binaries and libs for Windows ${{ matrix.arch }} 126 - name: Release pre-compiled binaries and libs for Windows ${{ matrix.arch }}
127 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 127 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
128 uses: svenstaro/upload-release-action@v2 128 uses: svenstaro/upload-release-action@v2
129 with: 129 with:
130 file_glob: true 130 file_glob: true
@@ -132,7 +132,7 @@ jobs: @@ -132,7 +132,7 @@ jobs:
132 file: ./mfc-examples/${{ matrix.arch }}/Release/sherpa-onnx-streaming-*.exe 132 file: ./mfc-examples/${{ matrix.arch }}/Release/sherpa-onnx-streaming-*.exe
133 133
134 - name: Release pre-compiled binaries and libs for Windows ${{ matrix.arch }} 134 - name: Release pre-compiled binaries and libs for Windows ${{ matrix.arch }}
135 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 135 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
136 uses: svenstaro/upload-release-action@v2 136 uses: svenstaro/upload-release-action@v2
137 with: 137 with:
138 file_glob: true 138 file_glob: true
1 name: release-go 1 name: release-go
2 2
3 on: 3 on:
4 - push:  
5 - tags:  
6 - - '*'  
7 -  
8 workflow_dispatch: 4 workflow_dispatch:
9 5
10 concurrency: 6 concurrency:
@@ -225,7 +225,7 @@ jobs: @@ -225,7 +225,7 @@ jobs:
225 225
226 # https://huggingface.co/docs/hub/spaces-github-actions 226 # https://huggingface.co/docs/hub/spaces-github-actions
227 - name: Publish to huggingface 227 - name: Publish to huggingface
228 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' 228 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' && github.event_name == 'workflow_dispatch')
229 env: 229 env:
230 HF_TOKEN: ${{ secrets.HF_TOKEN }} 230 HF_TOKEN: ${{ secrets.HF_TOKEN }}
231 uses: nick-fields/retry@v3 231 uses: nick-fields/retry@v3
@@ -269,7 +269,7 @@ jobs: @@ -269,7 +269,7 @@ jobs:
269 path: sherpa-onnx-*linux-riscv64-static.tar.bz2 269 path: sherpa-onnx-*linux-riscv64-static.tar.bz2
270 270
271 - name: Release pre-compiled binaries and libs for riscv64 linux ${{ matrix.lib_type }} 271 - name: Release pre-compiled binaries and libs for riscv64 linux ${{ matrix.lib_type }}
272 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 272 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
273 uses: svenstaro/upload-release-action@v2 273 uses: svenstaro/upload-release-action@v2
274 with: 274 with:
275 file_glob: true 275 file_glob: true
@@ -63,7 +63,7 @@ jobs: @@ -63,7 +63,7 @@ jobs:
63 63
64 - name: Run sccache-cache 64 - name: Run sccache-cache
65 if: matrix.os == 'windows-latest' 65 if: matrix.os == 'windows-latest'
66 - uses: mozilla-actions/sccache-action@v0.0.3 66 + uses: mozilla-actions/sccache-action@v0.0.4
67 with: 67 with:
68 version: "v0.7.4" 68 version: "v0.7.4"
69 69
@@ -33,7 +33,7 @@ jobs: @@ -33,7 +33,7 @@ jobs:
33 fetch-depth: 0 33 fetch-depth: 0
34 34
35 - name: Setup .NET 6.0 35 - name: Setup .NET 6.0
36 - uses: actions/setup-dotnet@v1 36 + uses: actions/setup-dotnet@v4
37 with: 37 with:
38 dotnet-version: 6.0.x 38 dotnet-version: 6.0.x
39 39
@@ -137,7 +137,7 @@ jobs: @@ -137,7 +137,7 @@ jobs:
137 path: /tmp/windows-x86 137 path: /tmp/windows-x86
138 138
139 - name: Setup .NET 139 - name: Setup .NET
140 - uses: actions/setup-dotnet@v3 140 + uses: actions/setup-dotnet@v4
141 with: 141 with:
142 dotnet-version: | 142 dotnet-version: |
143 6.0.x 143 6.0.x
@@ -133,7 +133,6 @@ jobs: @@ -133,7 +133,6 @@ jobs:
133 .github/scripts/test-online-transducer.sh 133 .github/scripts/test-online-transducer.sh
134 134
135 - name: Copy files 135 - name: Copy files
136 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/')  
137 shell: bash 136 shell: bash
138 run: | 137 run: |
139 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2) 138 SHERPA_ONNX_VERSION=v$(grep "SHERPA_ONNX_VERSION" ./CMakeLists.txt | cut -d " " -f 2 | cut -d '"' -f 2)
@@ -148,7 +147,7 @@ jobs: @@ -148,7 +147,7 @@ jobs:
148 tar cjvf ${dst}.tar.bz2 $dst 147 tar cjvf ${dst}.tar.bz2 $dst
149 148
150 - name: Release pre-compiled binaries and libs for Windows x64 CUDA 149 - name: Release pre-compiled binaries and libs for Windows x64 CUDA
151 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 150 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
152 uses: svenstaro/upload-release-action@v2 151 uses: svenstaro/upload-release-action@v2
153 with: 152 with:
154 file_glob: true 153 file_glob: true
@@ -154,7 +154,7 @@ jobs: @@ -154,7 +154,7 @@ jobs:
154 154
155 # https://huggingface.co/docs/hub/spaces-github-actions 155 # https://huggingface.co/docs/hub/spaces-github-actions
156 - name: Publish to huggingface 156 - name: Publish to huggingface
157 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' 157 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' && github.event_name == 'workflow_dispatch')
158 env: 158 env:
159 HF_TOKEN: ${{ secrets.HF_TOKEN }} 159 HF_TOKEN: ${{ secrets.HF_TOKEN }}
160 uses: nick-fields/retry@v3 160 uses: nick-fields/retry@v3
@@ -185,7 +185,7 @@ jobs: @@ -185,7 +185,7 @@ jobs:
185 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main 185 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main
186 186
187 - name: Release pre-compiled binaries and libs for Windows x64 187 - name: Release pre-compiled binaries and libs for Windows x64
188 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 188 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
189 uses: svenstaro/upload-release-action@v2 189 uses: svenstaro/upload-release-action@v2
190 with: 190 with:
191 file_glob: true 191 file_glob: true
@@ -157,7 +157,7 @@ jobs: @@ -157,7 +157,7 @@ jobs:
157 157
158 # https://huggingface.co/docs/hub/spaces-github-actions 158 # https://huggingface.co/docs/hub/spaces-github-actions
159 - name: Publish to huggingface 159 - name: Publish to huggingface
160 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' 160 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && (github.event_name == 'push' && github.event_name == 'workflow_dispatch')
161 env: 161 env:
162 HF_TOKEN: ${{ secrets.HF_TOKEN }} 162 HF_TOKEN: ${{ secrets.HF_TOKEN }}
163 uses: nick-fields/retry@v3 163 uses: nick-fields/retry@v3
@@ -188,7 +188,7 @@ jobs: @@ -188,7 +188,7 @@ jobs:
188 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main 188 git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/sherpa-onnx-libs main
189 189
190 - name: Release pre-compiled binaries and libs for Windows x86 190 - name: Release pre-compiled binaries and libs for Windows x86
191 - if: github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa' && github.event_name == 'push' && contains(github.ref, 'refs/tags/') 191 + if: (github.repository_owner == 'csukuangfj' || github.repository_owner == 'k2-fsa') && github.event_name == 'push' && contains(github.ref, 'refs/tags/')
192 uses: svenstaro/upload-release-action@v2 192 uses: svenstaro/upload-release-action@v2
193 with: 193 with:
194 file_glob: true 194 file_glob: true
1 function(download_kaldi_native_fbank) 1 function(download_kaldi_native_fbank)
2 include(FetchContent) 2 include(FetchContent)
3 3
4 - set(kaldi_native_fbank_URL "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.19.1.tar.gz") 4 + set(kaldi_native_fbank_URL "https://github.com/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.19.1.tar.gz")
  5 + set(kaldi_native_fbank_URL2 "https://hub.nuaa.cf/csukuangfj/kaldi-native-fbank/archive/refs/tags/v1.19.1.tar.gz")
5 set(kaldi_native_fbank_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/kaldi-native-fbank-1.19.1.tar.gz") 6 set(kaldi_native_fbank_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/kaldi-native-fbank-1.19.1.tar.gz")
6 set(kaldi_native_fbank_HASH "SHA256=0cae8cbb9ea42916b214e088912f9e8f2f648f54756b305f93f552382f31f904") 7 set(kaldi_native_fbank_HASH "SHA256=0cae8cbb9ea42916b214e088912f9e8f2f648f54756b305f93f552382f31f904")
7 8
@@ -12,11 +13,11 @@ function(download_kaldi_native_fbank) @@ -12,11 +13,11 @@ function(download_kaldi_native_fbank)
12 # If you don't have access to the Internet, 13 # If you don't have access to the Internet,
13 # please pre-download kaldi-native-fbank 14 # please pre-download kaldi-native-fbank
14 set(possible_file_locations 15 set(possible_file_locations
15 - $ENV{HOME}/Downloads/kaldi-native-fbank-1.18.7.tar.gz  
16 - ${CMAKE_SOURCE_DIR}/kaldi-native-fbank-1.18.7.tar.gz  
17 - ${CMAKE_BINARY_DIR}/kaldi-native-fbank-1.18.7.tar.gz  
18 - /tmp/kaldi-native-fbank-1.18.7.tar.gz  
19 - /star-fj/fangjun/download/github/kaldi-native-fbank-1.18.7.tar.gz 16 + $ENV{HOME}/Downloads/kaldi-native-fbank-1.19.1.tar.gz
  17 + ${CMAKE_SOURCE_DIR}/kaldi-native-fbank-1.19.1.tar.gz
  18 + ${CMAKE_BINARY_DIR}/kaldi-native-fbank-1.19.1.tar.gz
  19 + /tmp/kaldi-native-fbank-1.19.1.tar.gz
  20 + /star-fj/fangjun/download/github/kaldi-native-fbank-1.19.1.tar.gz
20 ) 21 )
21 22
22 foreach(f IN LISTS possible_file_locations) 23 foreach(f IN LISTS possible_file_locations)
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 set -ex 3 set -ex
4 4
5 if [ ! -d ./sherpa-onnx-zipformer-en-2023-04-01 ]; then 5 if [ ! -d ./sherpa-onnx-zipformer-en-2023-04-01 ]; then
6 - wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-zipformer-en-2023-04-01.tar.bz2 6 + wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-zipformer-en-2023-04-01.tar.bz2
7 tar xvf sherpa-onnx-zipformer-en-2023-04-01.tar.bz2 7 tar xvf sherpa-onnx-zipformer-en-2023-04-01.tar.bz2
8 rm sherpa-onnx-zipformer-en-2023-04-01.tar.bz2 8 rm sherpa-onnx-zipformer-en-2023-04-01.tar.bz2
9 fi 9 fi
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 set -ex 3 set -ex
4 4
5 if [ ! -d ./sherpa-onnx-zipformer-en-2023-04-01 ]; then 5 if [ ! -d ./sherpa-onnx-zipformer-en-2023-04-01 ]; then
6 - wget https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-zipformer-en-2023-04-01.tar.bz2 6 + wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-zipformer-en-2023-04-01.tar.bz2
7 tar xvf sherpa-onnx-zipformer-en-2023-04-01.tar.bz2 7 tar xvf sherpa-onnx-zipformer-en-2023-04-01.tar.bz2
8 rm sherpa-onnx-zipformer-en-2023-04-01.tar.bz2 8 rm sherpa-onnx-zipformer-en-2023-04-01.tar.bz2
9 fi 9 fi
@@ -226,10 +226,16 @@ to download pre-trained streaming models. @@ -226,10 +226,16 @@ to download pre-trained streaming models.
226 // display results 226 // display results
227 for (int i = 0; i != files.Length; ++i) 227 for (int i = 0; i != files.Length; ++i)
228 { 228 {
229 - var text = recognizer.GetResult(streams[i]).Text; 229 + OnlineRecognizerResult r = recognizer.GetResult(streams[i]);
  230 + var text = r.Text;
  231 + var tokens = r.Tokens;
230 Console.WriteLine("--------------------"); 232 Console.WriteLine("--------------------");
231 Console.WriteLine(files[i]); 233 Console.WriteLine(files[i]);
232 - Console.WriteLine(text); 234 + Console.WriteLine("text: {0}", text);
  235 + Console.WriteLine("tokens: [{0}]", string.Join(", ", tokens));
  236 + Console.Write("timestamps: [");
  237 + r.Timestamps.ToList().ForEach(i => Console.Write(String.Format("{0:0.00}", i) + ", "));
  238 + Console.WriteLine("]");
233 } 239 }
234 Console.WriteLine("--------------------"); 240 Console.WriteLine("--------------------");
235 } 241 }
@@ -6,10 +6,8 @@ @@ -6,10 +6,8 @@
6 6
7 set -ex 7 set -ex
8 if [ ! -d ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 ]; then 8 if [ ! -d ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 ]; then
9 - GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20  
10 - cd sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20  
11 - git lfs pull --include "*.onnx"  
12 - cd .. 9 + wget -q https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
  10 + tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
13 fi 11 fi
14 12
15 dotnet run -c Release \ 13 dotnet run -c Release \
@@ -185,23 +185,82 @@ namespace SherpaOnnx @@ -185,23 +185,82 @@ namespace SherpaOnnx
185 while (*buffer != 0) 185 while (*buffer != 0)
186 { 186 {
187 ++buffer; 187 ++buffer;
  188 + length += 1;
188 } 189 }
189 - length = (int)(buffer - (byte*)impl.Text);  
190 } 190 }
191 191
192 byte[] stringBuffer = new byte[length]; 192 byte[] stringBuffer = new byte[length];
193 Marshal.Copy(impl.Text, stringBuffer, 0, length); 193 Marshal.Copy(impl.Text, stringBuffer, 0, length);
194 _text = Encoding.UTF8.GetString(stringBuffer); 194 _text = Encoding.UTF8.GetString(stringBuffer);
  195 +
  196 + _tokens = new String[impl.Count];
  197 +
  198 + unsafe
  199 + {
  200 + byte* buf = (byte*)impl.Tokens;
  201 + for (int i = 0; i < impl.Count; i++)
  202 + {
  203 + length = 0;
  204 + byte* start = buf;
  205 + while (*buf != 0)
  206 + {
  207 + ++buf;
  208 + length += 1;
  209 + }
  210 + ++buf;
  211 +
  212 + stringBuffer = new byte[length];
  213 + fixed (byte* pTarget = stringBuffer)
  214 + {
  215 + for (int k = 0; k < length; k++)
  216 + {
  217 + pTarget[k] = start[k];
  218 + }
  219 + }
  220 +
  221 + _tokens[i] = Encoding.UTF8.GetString(stringBuffer);
  222 + }
  223 + }
  224 +
  225 + unsafe
  226 + {
  227 + float* t = (float*)impl.Timestamps;
  228 + if (t != null)
  229 + {
  230 + _timestamps = new float[impl.Count];
  231 + fixed (float* pTarget = _timestamps)
  232 + {
  233 + for (int i = 0; i < impl.Count; i++)
  234 + {
  235 + pTarget[i] = t[i];
  236 + }
  237 + }
  238 + }
  239 + else
  240 + {
  241 + _timestamps = Array.Empty<float>();
  242 + }
  243 + }
195 } 244 }
196 245
197 [StructLayout(LayoutKind.Sequential)] 246 [StructLayout(LayoutKind.Sequential)]
198 struct Impl 247 struct Impl
199 { 248 {
200 public IntPtr Text; 249 public IntPtr Text;
  250 + public IntPtr Tokens;
  251 + public IntPtr TokensArr;
  252 + public IntPtr Timestamps;
  253 + public int Count;
201 } 254 }
202 255
203 private String _text; 256 private String _text;
204 public String Text => _text; 257 public String Text => _text;
  258 +
  259 + private String[] _tokens;
  260 + public String[] Tokens => _tokens;
  261 +
  262 + private float[] _timestamps;
  263 + public float[] Timestamps => _timestamps;
205 } 264 }
206 265
207 public class OnlineStream : IDisposable 266 public class OnlineStream : IDisposable
@@ -162,15 +162,17 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult( @@ -162,15 +162,17 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult(
162 memset(r, 0, sizeof(SherpaOnnxOnlineRecognizerResult)); 162 memset(r, 0, sizeof(SherpaOnnxOnlineRecognizerResult));
163 163
164 // copy text 164 // copy text
165 - r->text = new char[text.size() + 1];  
166 - std::copy(text.begin(), text.end(), const_cast<char *>(r->text));  
167 - const_cast<char *>(r->text)[text.size()] = 0; 165 + char *pText = new char[text.size() + 1];
  166 + std::copy(text.begin(), text.end(), pText);
  167 + pText[text.size()] = 0;
  168 + r->text = pText;
168 169
169 // copy json 170 // copy json
170 const auto &json = result.AsJsonString(); 171 const auto &json = result.AsJsonString();
171 - r->json = new char[json.size() + 1];  
172 - std::copy(json.begin(), json.end(), const_cast<char *>(r->json));  
173 - const_cast<char *>(r->json)[json.size()] = 0; 172 + char *pJson = new char[json.size() + 1];
  173 + std::copy(json.begin(), json.end(), pJson);
  174 + pJson[json.size()] = 0;
  175 + r->json = pJson;
174 176
175 // copy tokens 177 // copy tokens
176 auto count = result.tokens.size(); 178 auto count = result.tokens.size();
@@ -183,15 +185,12 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult( @@ -183,15 +185,12 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult(
183 185
184 r->count = count; 186 r->count = count;
185 // Each word ends with nullptr 187 // Each word ends with nullptr
186 - r->tokens = new char[total_length];  
187 - memset(reinterpret_cast<void *>(const_cast<char *>(r->tokens)), 0,  
188 - total_length); 188 + char *tokens = new char[total_length]{};
189 char **tokens_temp = new char *[r->count]; 189 char **tokens_temp = new char *[r->count];
190 int32_t pos = 0; 190 int32_t pos = 0;
191 for (int32_t i = 0; i < r->count; ++i) { 191 for (int32_t i = 0; i < r->count; ++i) {
192 - tokens_temp[i] = const_cast<char *>(r->tokens) + pos;  
193 - memcpy(reinterpret_cast<void *>(const_cast<char *>(r->tokens + pos)),  
194 - result.tokens[i].c_str(), result.tokens[i].size()); 192 + tokens_temp[i] = tokens + pos;
  193 + memcpy(tokens + pos, result.tokens[i].c_str(), result.tokens[i].size());
195 // +1 to move past the null character 194 // +1 to move past the null character
196 pos += result.tokens[i].size() + 1; 195 pos += result.tokens[i].size() + 1;
197 } 196 }
@@ -205,6 +204,7 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult( @@ -205,6 +204,7 @@ const SherpaOnnxOnlineRecognizerResult *GetOnlineStreamResult(
205 r->timestamps = nullptr; 204 r->timestamps = nullptr;
206 } 205 }
207 206
  207 + r->tokens = tokens;
208 } else { 208 } else {
209 r->count = 0; 209 r->count = 0;
210 r->timestamps = nullptr; 210 r->timestamps = nullptr;
@@ -391,9 +391,10 @@ const SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult( @@ -391,9 +391,10 @@ const SherpaOnnxOfflineRecognizerResult *GetOfflineStreamResult(
391 auto r = new SherpaOnnxOfflineRecognizerResult; 391 auto r = new SherpaOnnxOfflineRecognizerResult;
392 memset(r, 0, sizeof(SherpaOnnxOfflineRecognizerResult)); 392 memset(r, 0, sizeof(SherpaOnnxOfflineRecognizerResult));
393 393
394 - r->text = new char[text.size() + 1];  
395 - std::copy(text.begin(), text.end(), const_cast<char *>(r->text));  
396 - const_cast<char *>(r->text)[text.size()] = 0; 394 + char *pText = new char[text.size() + 1];
  395 + std::copy(text.begin(), text.end(), pText);
  396 + pText[text.size()] = 0;
  397 + r->text = pText;
397 398
398 if (!result.timestamps.empty()) { 399 if (!result.timestamps.empty()) {
399 r->timestamps = new float[result.timestamps.size()]; 400 r->timestamps = new float[result.timestamps.size()];
@@ -530,15 +531,17 @@ const SherpaOnnxKeywordResult *GetKeywordResult( @@ -530,15 +531,17 @@ const SherpaOnnxKeywordResult *GetKeywordResult(
530 r->start_time = result.start_time; 531 r->start_time = result.start_time;
531 532
532 // copy keyword 533 // copy keyword
533 - r->keyword = new char[keyword.size() + 1];  
534 - std::copy(keyword.begin(), keyword.end(), const_cast<char *>(r->keyword));  
535 - const_cast<char *>(r->keyword)[keyword.size()] = 0; 534 + char *pKeyword = new char[keyword.size() + 1];
  535 + std::copy(keyword.begin(), keyword.end(), pKeyword);
  536 + pKeyword[keyword.size()] = 0;
  537 + r->keyword = pKeyword;
536 538
537 // copy json 539 // copy json
538 const auto &json = result.AsJsonString(); 540 const auto &json = result.AsJsonString();
539 - r->json = new char[json.size() + 1];  
540 - std::copy(json.begin(), json.end(), const_cast<char *>(r->json));  
541 - const_cast<char *>(r->json)[json.size()] = 0; 541 + char *pJson = new char[json.size() + 1];
  542 + std::copy(json.begin(), json.end(), pJson);
  543 + pJson[json.size()] = 0;
  544 + r->json = pJson;
542 545
543 // copy tokens 546 // copy tokens
544 auto count = result.tokens.size(); 547 auto count = result.tokens.size();
@@ -551,18 +554,16 @@ const SherpaOnnxKeywordResult *GetKeywordResult( @@ -551,18 +554,16 @@ const SherpaOnnxKeywordResult *GetKeywordResult(
551 554
552 r->count = count; 555 r->count = count;
553 // Each word ends with nullptr 556 // Each word ends with nullptr
554 - r->tokens = new char[total_length];  
555 - memset(reinterpret_cast<void *>(const_cast<char *>(r->tokens)), 0,  
556 - total_length); 557 + char *pTokens = new char[total_length]{};
557 char **tokens_temp = new char *[r->count]; 558 char **tokens_temp = new char *[r->count];
558 int32_t pos = 0; 559 int32_t pos = 0;
559 for (int32_t i = 0; i < r->count; ++i) { 560 for (int32_t i = 0; i < r->count; ++i) {
560 - tokens_temp[i] = const_cast<char *>(r->tokens) + pos;  
561 - memcpy(reinterpret_cast<void *>(const_cast<char *>(r->tokens + pos)),  
562 - result.tokens[i].c_str(), result.tokens[i].size()); 561 + tokens_temp[i] = pTokens + pos;
  562 + memcpy(pTokens + pos, result.tokens[i].c_str(), result.tokens[i].size());
563 // +1 to move past the null character 563 // +1 to move past the null character
564 pos += result.tokens[i].size() + 1; 564 pos += result.tokens[i].size() + 1;
565 } 565 }
  566 + r->tokens = pTokens;
566 r->tokens_arr = tokens_temp; 567 r->tokens_arr = tokens_temp;
567 568
568 if (!result.timestamps.empty()) { 569 if (!result.timestamps.empty()) {
@@ -145,6 +145,10 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerResult { @@ -145,6 +145,10 @@ SHERPA_ONNX_API typedef struct SherpaOnnxOnlineRecognizerResult {
145 const char *const *tokens_arr; 145 const char *const *tokens_arr;
146 146
147 // Pointer to continuous memory which holds timestamps 147 // Pointer to continuous memory which holds timestamps
  148 + //
  149 + // Caution: If timestamp information is not available, this pointer is NULL.
  150 + // Please check whether it is NULL before you access it; otherwise, you would
  151 + // get segmentation fault.
148 float *timestamps; 152 float *timestamps;
149 153
150 // The number of tokens/timestamps in above pointer 154 // The number of tokens/timestamps in above pointer
@@ -105,7 +105,7 @@ class OnlineZipformer2TransducerModel : public OnlineTransducerModel { @@ -105,7 +105,7 @@ class OnlineZipformer2TransducerModel : public OnlineTransducerModel {
105 105
106 int32_t context_size_ = 0; 106 int32_t context_size_ = 0;
107 int32_t vocab_size_ = 0; 107 int32_t vocab_size_ = 0;
108 - int32_t feature_dim_ = 0; 108 + int32_t feature_dim_ = 80;
109 }; 109 };
110 110
111 } // namespace sherpa_onnx 111 } // namespace sherpa_onnx