Refactor WebAssembly for nodejs (#626)

This commit is contained in:
Fangjun Kuang
2024-03-02 12:31:36 +08:00
committed by GitHub
parent a65643b594
commit ac6825ff11
16 changed files with 53 additions and 29 deletions

View File

@@ -72,7 +72,7 @@ jobs:
path: ./sherpa-onnx-wasm-simd-*.tar.bz2 path: ./sherpa-onnx-wasm-simd-*.tar.bz2
- name: Publish to ModelScope - name: Publish to ModelScope
if: false # if: false
env: env:
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }}
uses: nick-fields/retry@v2 uses: nick-fields/retry@v2
@@ -92,6 +92,9 @@ jobs:
git clone http://www.modelscope.cn/studios/k2-fsa/web-assembly-tts-sherpa-onnx-de.git ms git clone http://www.modelscope.cn/studios/k2-fsa/web-assembly-tts-sherpa-onnx-de.git ms
cd ms cd ms
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main
@@ -126,6 +129,8 @@ jobs:
git clone https://huggingface.co/spaces/k2-fsa/web-assembly-tts-sherpa-onnx-de huggingface git clone https://huggingface.co/spaces/k2-fsa/web-assembly-tts-sherpa-onnx-de huggingface
cd huggingface cd huggingface
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main

View File

@@ -74,7 +74,7 @@ jobs:
path: ./sherpa-onnx-wasm-simd-*.tar.bz2 path: ./sherpa-onnx-wasm-simd-*.tar.bz2
- name: Publish to ModelScope - name: Publish to ModelScope
if: false # if: false
env: env:
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }}
uses: nick-fields/retry@v2 uses: nick-fields/retry@v2
@@ -93,6 +93,8 @@ jobs:
git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-en.git ms git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-en.git ms
cd ms cd ms
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main
@@ -127,6 +129,8 @@ jobs:
git clone https://huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-en huggingface git clone https://huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-en huggingface
cd huggingface cd huggingface
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main

View File

@@ -70,7 +70,7 @@ jobs:
path: ./sherpa-onnx-wasm-simd-*.tar.bz2 path: ./sherpa-onnx-wasm-simd-*.tar.bz2
- name: Publish to ModelScope - name: Publish to ModelScope
if: false # if: false
env: env:
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }}
uses: nick-fields/retry@v2 uses: nick-fields/retry@v2
@@ -89,6 +89,8 @@ jobs:
git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-tts-sherpa-onnx-en.git ms git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-tts-sherpa-onnx-en.git ms
cd ms cd ms
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main
@@ -123,6 +125,8 @@ jobs:
git clone https://huggingface.co/spaces/k2-fsa/web-assembly-tts-sherpa-onnx-en huggingface git clone https://huggingface.co/spaces/k2-fsa/web-assembly-tts-sherpa-onnx-en huggingface
cd huggingface cd huggingface
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main

View File

@@ -99,6 +99,8 @@ jobs:
git clone https://huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer huggingface git clone https://huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer huggingface
cd huggingface cd huggingface
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main
@@ -115,7 +117,7 @@ jobs:
git push https://csukuangfj:$HF_TOKEN@huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer main git push https://csukuangfj:$HF_TOKEN@huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer main
- name: Publish to ModelScope - name: Publish to ModelScope
if: false # if: false
env: env:
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }}
uses: nick-fields/retry@v2 uses: nick-fields/retry@v2
@@ -134,6 +136,8 @@ jobs:
git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer.git ms git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-zh-cantonese-en-paraformer.git ms
cd ms cd ms
rm -fv *.js
rm -fv *.data
git config lfs.locksverify true git config lfs.locksverify true
git fetch git fetch
git pull git pull

View File

@@ -81,7 +81,7 @@ jobs:
path: ./sherpa-onnx-wasm-simd-*.tar.bz2 path: ./sherpa-onnx-wasm-simd-*.tar.bz2
- name: Publish to ModelScope - name: Publish to ModelScope
if: false # if: false
env: env:
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }}
uses: nick-fields/retry@v2 uses: nick-fields/retry@v2
@@ -100,6 +100,8 @@ jobs:
git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-zh-en-paraformer.git ms git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-zh-en-paraformer.git ms
cd ms cd ms
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main
@@ -134,6 +136,8 @@ jobs:
git clone https://huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-en-paraformer huggingface git clone https://huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-en-paraformer huggingface
cd huggingface cd huggingface
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main

View File

@@ -72,7 +72,7 @@ jobs:
path: ./sherpa-onnx-wasm-simd-*.tar.bz2 path: ./sherpa-onnx-wasm-simd-*.tar.bz2
- name: Publish to ModelScope - name: Publish to ModelScope
if: false # if: false
env: env:
MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }} MS_TOKEN: ${{ secrets.MODEL_SCOPE_GIT_TOKEN }}
uses: nick-fields/retry@v2 uses: nick-fields/retry@v2
@@ -91,6 +91,8 @@ jobs:
git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-zh-en.git ms git clone https://www.modelscope.cn/studios/k2-fsa/web-assembly-asr-sherpa-onnx-zh-en.git ms
cd ms cd ms
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main
@@ -125,6 +127,8 @@ jobs:
git clone https://huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-en huggingface git clone https://huggingface.co/spaces/k2-fsa/web-assembly-asr-sherpa-onnx-zh-en huggingface
cd huggingface cd huggingface
rm -fv *.js
rm -fv *.data
git fetch git fetch
git pull git pull
git merge -m "merge remote" --ff origin main git merge -m "merge remote" --ff origin main

View File

@@ -45,18 +45,18 @@ if (NOT CMAKE_EXECUTABLE_SUFFIX STREQUAL ".js")
endif() endif()
# set(CMAKE_EXECUTABLE_SUFFIX ".html") # set(CMAKE_EXECUTABLE_SUFFIX ".html")
add_executable(sherpa-onnx-wasm-asr-main sherpa-onnx-wasm-asr-main.cc) add_executable(sherpa-onnx-wasm-main-asr sherpa-onnx-wasm-main-asr.cc)
target_link_libraries(sherpa-onnx-wasm-asr-main sherpa-onnx-c-api) target_link_libraries(sherpa-onnx-wasm-main-asr sherpa-onnx-c-api)
install(TARGETS sherpa-onnx-wasm-asr-main DESTINATION bin/wasm/asr) install(TARGETS sherpa-onnx-wasm-main-asr DESTINATION bin/wasm/asr)
install( install(
FILES FILES
"$<TARGET_FILE_DIR:sherpa-onnx-wasm-asr-main>/sherpa-onnx-wasm-asr-main.js" "$<TARGET_FILE_DIR:sherpa-onnx-wasm-main-asr>/sherpa-onnx-wasm-main-asr.js"
"index.html" "index.html"
"sherpa-onnx.js" "sherpa-onnx-asr.js"
"app.js" "app-asr.js"
"$<TARGET_FILE_DIR:sherpa-onnx-wasm-asr-main>/sherpa-onnx-wasm-asr-main.wasm" "$<TARGET_FILE_DIR:sherpa-onnx-wasm-main-asr>/sherpa-onnx-wasm-main-asr.wasm"
"$<TARGET_FILE_DIR:sherpa-onnx-wasm-asr-main>/sherpa-onnx-wasm-asr-main.data" "$<TARGET_FILE_DIR:sherpa-onnx-wasm-main-asr>/sherpa-onnx-wasm-main-asr.data"
DESTINATION DESTINATION
bin/wasm/asr bin/wasm/asr
) )

View File

@@ -36,7 +36,7 @@
<section flex="1" overflow="auto" id="sound-clips"> <section flex="1" overflow="auto" id="sound-clips">
</section> </section>
<script src="sherpa-onnx.js"></script> <script src="sherpa-onnx-asr.js"></script>
<script src="app.js"></script> <script src="app-asr.js"></script>
<script src="sherpa-onnx-wasm-asr-main.js"></script> <script src="sherpa-onnx-wasm-main-asr.js"></script>
</body> </body>

View File

@@ -40,19 +40,18 @@ if (NOT CMAKE_EXECUTABLE_SUFFIX STREQUAL ".js")
endif() endif()
# set(CMAKE_EXECUTABLE_SUFFIX ".html") # set(CMAKE_EXECUTABLE_SUFFIX ".html")
add_executable(sherpa-onnx-wasm-main sherpa-onnx-wasm-main.cc) add_executable(sherpa-onnx-wasm-main-tts sherpa-onnx-wasm-main-tts.cc)
target_link_libraries(sherpa-onnx-wasm-main sherpa-onnx-c-api) target_link_libraries(sherpa-onnx-wasm-main-tts sherpa-onnx-c-api)
install(TARGETS sherpa-onnx-wasm-main DESTINATION bin/wasm/tts) install(TARGETS sherpa-onnx-wasm-main-tts DESTINATION bin/wasm/tts)
install( install(
FILES FILES
"$<TARGET_FILE_DIR:sherpa-onnx-wasm-main>/sherpa-onnx-wasm-main.js" "$<TARGET_FILE_DIR:sherpa-onnx-wasm-main-tts>/sherpa-onnx-wasm-main-tts.js"
"index.html" "index.html"
"sherpa-onnx.js" "sherpa-onnx-tts.js"
"app.js" "app-tts.js"
"$<TARGET_FILE_DIR:sherpa-onnx-wasm-main>/sherpa-onnx-wasm-main.wasm" "$<TARGET_FILE_DIR:sherpa-onnx-wasm-main-tts>/sherpa-onnx-wasm-main-tts.wasm"
"$<TARGET_FILE_DIR:sherpa-onnx-wasm-main>/sherpa-onnx-wasm-main.data" "$<TARGET_FILE_DIR:sherpa-onnx-wasm-main-tts>/sherpa-onnx-wasm-main-tts.data"
# "$<TARGET_FILE_DIR:sherpa-onnx-wasm-main>/sherpa-onnx-wasm-main.html"
DESTINATION DESTINATION
bin/wasm/tts bin/wasm/tts
) )

View File

@@ -40,7 +40,7 @@
<section flex="1" overflow="auto" id="sound-clips"> <section flex="1" overflow="auto" id="sound-clips">
</section> </section>
<script src="app.js"></script> <script src="app-tts.js"></script>
<script src="sherpa-onnx.js"></script> <script src="sherpa-onnx-tts.js"></script>
<script src="sherpa-onnx-wasm-main.js"></script> <script src="sherpa-onnx-wasm-main-tts.js"></script>
</body> </body>