Fangjun Kuang
Committed by GitHub

Fix CI tests for Python and JNI. (#554)

@@ -48,8 +48,9 @@ jobs: @@ -48,8 +48,9 @@ jobs:
48 shell: bash 48 shell: bash
49 run: | 49 run: |
50 pip install --verbose sherpa-onnx 50 pip install --verbose sherpa-onnx
  51 + # python3 -m pip install --verbose .
51 52
52 - - name: Test sherp-onnx 53 + - name: Test sherpa-onnx
53 shell: bash 54 shell: bash
54 run: | 55 run: |
55 python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)" 56 python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)"
@@ -68,8 +69,8 @@ jobs: @@ -68,8 +69,8 @@ jobs:
68 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH 69 export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH
69 export PATH=/c/hostedtoolcache/windows/Python/3.11.7/x64/bin:$PATH 70 export PATH=/c/hostedtoolcache/windows/Python/3.11.7/x64/bin:$PATH
70 71
71 -  
72 sherpa-onnx --help 72 sherpa-onnx --help
  73 + sherpa-onnx-keyword-spotter --help
73 sherpa-onnx-offline --help 74 sherpa-onnx-offline --help
74 sherpa-onnx-offline-tts --help 75 sherpa-onnx-offline-tts --help
75 76
@@ -2,9 +2,8 @@ package com.k2fsa.sherpa.onnx @@ -2,9 +2,8 @@ package com.k2fsa.sherpa.onnx
2 2
3 import android.content.res.AssetManager 3 import android.content.res.AssetManager
4 import android.util.Log 4 import android.util.Log
5 -import com.k2fsa.sherpa.onnx.speaker.identification.TAG  
6 -  
7 5
  6 +private val TAG = "sherpa-onnx"
8 data class SpeakerEmbeddingExtractorConfig( 7 data class SpeakerEmbeddingExtractorConfig(
9 val model: String, 8 val model: String,
10 var numThreads: Int = 1, 9 var numThreads: Int = 1,
  1 +package android.util
  2 +
  3 +class Log {
  4 + companion object {
  5 + fun i(tag: String, msg: String) {
  6 + println("$tag, $msg")
  7 + }
  8 + }
  9 +}
  10 +
@@ -62,7 +62,7 @@ if [ ! -f ./vits-piper-en_US-amy-low/en_US-amy-low.onnx ]; then @@ -62,7 +62,7 @@ if [ ! -f ./vits-piper-en_US-amy-low/en_US-amy-low.onnx ]; then
62 rm vits-piper-en_US-amy-low.tar.bz2 62 rm vits-piper-en_US-amy-low.tar.bz2
63 fi 63 fi
64 64
65 -kotlinc-jvm -include-runtime -d main.jar Main.kt WaveReader.kt SherpaOnnx.kt faked-asset-manager.kt Tts.kt Speaker.kt 65 +kotlinc-jvm -include-runtime -d main.jar Main.kt WaveReader.kt SherpaOnnx.kt faked-asset-manager.kt Tts.kt Speaker.kt faked-log.kt
66 66
67 ls -lh main.jar 67 ls -lh main.jar
68 68
@@ -36,13 +36,6 @@ package_name = "sherpa-onnx" @@ -36,13 +36,6 @@ package_name = "sherpa-onnx"
36 with open("sherpa-onnx/python/sherpa_onnx/__init__.py", "a") as f: 36 with open("sherpa-onnx/python/sherpa_onnx/__init__.py", "a") as f:
37 f.write(f"__version__ = '{get_package_version()}'\n") 37 f.write(f"__version__ = '{get_package_version()}'\n")
38 38
39 -install_requires = [  
40 - "numpy",  
41 - "sentencepiece==0.1.96; python_version < '3.11'",  
42 - "sentencepiece; python_version >= '3.11'",  
43 - "click>=7.1.1",  
44 -]  
45 -  
46 39
47 def get_binaries_to_install(): 40 def get_binaries_to_install():
48 bin_dir = Path("build") / "sherpa_onnx" / "bin" 41 bin_dir = Path("build") / "sherpa_onnx" / "bin"
@@ -91,7 +84,6 @@ def get_binaries_to_install(): @@ -91,7 +84,6 @@ def get_binaries_to_install():
91 setuptools.setup( 84 setuptools.setup(
92 name=package_name, 85 name=package_name,
93 python_requires=">=3.6", 86 python_requires=">=3.6",
94 - install_requires=install_requires,  
95 version=get_package_version(), 87 version=get_package_version(),
96 author="The sherpa-onnx development team", 88 author="The sherpa-onnx development team",
97 author_email="dpovey@gmail.com", 89 author_email="dpovey@gmail.com",
1 # Copyright (c) 2023 Xiaomi Corporation 1 # Copyright (c) 2023 Xiaomi Corporation
2 2
3 import logging 3 import logging
4 -import click 4 +try:
  5 + import click
  6 +except ImportError:
  7 + print('Please run')
  8 + print(' pip install click')
  9 + print('before you continue')
  10 + raise
  11 +
5 from pathlib import Path 12 from pathlib import Path
6 from sherpa_onnx import text2token 13 from sherpa_onnx import text2token
7 14
@@ -4,12 +4,6 @@ import re @@ -4,12 +4,6 @@ import re
4 from pathlib import Path 4 from pathlib import Path
5 from typing import List, Optional, Union 5 from typing import List, Optional, Union
6 6
7 -import sentencepiece as spm  
8 -  
9 -from pypinyin import pinyin  
10 -from pypinyin.contrib.tone_convert import to_initials, to_finals_tone  
11 -  
12 -  
13 def text2token( 7 def text2token(
14 texts: List[str], 8 texts: List[str],
15 tokens: str, 9 tokens: str,
@@ -38,6 +32,23 @@ def text2token( @@ -38,6 +32,23 @@ def text2token(
38 Return the encoded texts, it is a list of a list of token ids if output_ids 32 Return the encoded texts, it is a list of a list of token ids if output_ids
39 is True, or it is a list of list of tokens. 33 is True, or it is a list of list of tokens.
40 """ 34 """
  35 + try:
  36 + import sentencepiece as spm
  37 + except ImportError:
  38 + print('Please run')
  39 + print(' pip install sentencepiece')
  40 + print('before you continue')
  41 + raise
  42 +
  43 + try:
  44 + from pypinyin import pinyin
  45 + from pypinyin.contrib.tone_convert import to_initials, to_finals_tone
  46 + except ImportError:
  47 + print('Please run')
  48 + print(' pip install pypinyin')
  49 + print('before you continue')
  50 + raise
  51 +
41 assert Path(tokens).is_file(), f"File not exists, {tokens}" 52 assert Path(tokens).is_file(), f"File not exists, {tokens}"
42 tokens_table = {} 53 tokens_table = {}
43 with open(tokens, "r", encoding="utf-8") as f: 54 with open(tokens, "r", encoding="utf-8") as f: