diff --git a/.github/workflows/test-pip-install.yaml b/.github/workflows/test-pip-install.yaml index 264c5027..e6c004ed 100644 --- a/.github/workflows/test-pip-install.yaml +++ b/.github/workflows/test-pip-install.yaml @@ -48,8 +48,9 @@ jobs: shell: bash run: | pip install --verbose sherpa-onnx + # python3 -m pip install --verbose . - - name: Test sherp-onnx + - name: Test sherpa-onnx shell: bash run: | python3 -c "import sherpa_onnx; print(sherpa_onnx.__file__)" @@ -68,8 +69,8 @@ jobs: export PATH=/c/hostedtoolcache/windows/Python/3.10.11/x64/bin:$PATH export PATH=/c/hostedtoolcache/windows/Python/3.11.7/x64/bin:$PATH - sherpa-onnx --help + sherpa-onnx-keyword-spotter --help sherpa-onnx-offline --help sherpa-onnx-offline-tts --help diff --git a/android/SherpaOnnxSpeakerIdentification/app/src/main/java/com/k2fsa/sherpa/onnx/speaker/identification/Speaker.kt b/android/SherpaOnnxSpeakerIdentification/app/src/main/java/com/k2fsa/sherpa/onnx/speaker/identification/Speaker.kt index e3dc62fa..4c9bd06f 100644 --- a/android/SherpaOnnxSpeakerIdentification/app/src/main/java/com/k2fsa/sherpa/onnx/speaker/identification/Speaker.kt +++ b/android/SherpaOnnxSpeakerIdentification/app/src/main/java/com/k2fsa/sherpa/onnx/speaker/identification/Speaker.kt @@ -2,9 +2,8 @@ package com.k2fsa.sherpa.onnx import android.content.res.AssetManager import android.util.Log -import com.k2fsa.sherpa.onnx.speaker.identification.TAG - +private val TAG = "sherpa-onnx" data class SpeakerEmbeddingExtractorConfig( val model: String, var numThreads: Int = 1, diff --git a/kotlin-api-examples/faked-log.kt b/kotlin-api-examples/faked-log.kt new file mode 100644 index 00000000..e25d5a31 --- /dev/null +++ b/kotlin-api-examples/faked-log.kt @@ -0,0 +1,10 @@ +package android.util + +class Log { + companion object { + fun i(tag: String, msg: String) { + println("$tag, $msg") + } + } +} + diff --git a/kotlin-api-examples/run.sh b/kotlin-api-examples/run.sh index c6c4c41a..0a0b38d8 100755 --- a/kotlin-api-examples/run.sh +++ b/kotlin-api-examples/run.sh @@ -62,7 +62,7 @@ if [ ! -f ./vits-piper-en_US-amy-low/en_US-amy-low.onnx ]; then rm vits-piper-en_US-amy-low.tar.bz2 fi -kotlinc-jvm -include-runtime -d main.jar Main.kt WaveReader.kt SherpaOnnx.kt faked-asset-manager.kt Tts.kt Speaker.kt +kotlinc-jvm -include-runtime -d main.jar Main.kt WaveReader.kt SherpaOnnx.kt faked-asset-manager.kt Tts.kt Speaker.kt faked-log.kt ls -lh main.jar diff --git a/setup.py b/setup.py index fc2f5677..42ec86f1 100644 --- a/setup.py +++ b/setup.py @@ -36,13 +36,6 @@ package_name = "sherpa-onnx" with open("sherpa-onnx/python/sherpa_onnx/__init__.py", "a") as f: f.write(f"__version__ = '{get_package_version()}'\n") -install_requires = [ - "numpy", - "sentencepiece==0.1.96; python_version < '3.11'", - "sentencepiece; python_version >= '3.11'", - "click>=7.1.1", -] - def get_binaries_to_install(): bin_dir = Path("build") / "sherpa_onnx" / "bin" @@ -91,7 +84,6 @@ def get_binaries_to_install(): setuptools.setup( name=package_name, python_requires=">=3.6", - install_requires=install_requires, version=get_package_version(), author="The sherpa-onnx development team", author_email="dpovey@gmail.com", diff --git a/sherpa-onnx/python/sherpa_onnx/cli.py b/sherpa-onnx/python/sherpa_onnx/cli.py index 6d9de47d..0527e20a 100644 --- a/sherpa-onnx/python/sherpa_onnx/cli.py +++ b/sherpa-onnx/python/sherpa_onnx/cli.py @@ -1,7 +1,14 @@ # Copyright (c) 2023 Xiaomi Corporation import logging -import click +try: + import click +except ImportError: + print('Please run') + print(' pip install click') + print('before you continue') + raise + from pathlib import Path from sherpa_onnx import text2token diff --git a/sherpa-onnx/python/sherpa_onnx/utils.py b/sherpa-onnx/python/sherpa_onnx/utils.py index e2c2d24a..7b152a95 100644 --- a/sherpa-onnx/python/sherpa_onnx/utils.py +++ b/sherpa-onnx/python/sherpa_onnx/utils.py @@ -4,12 +4,6 @@ import re from pathlib import Path from typing import List, Optional, Union -import sentencepiece as spm - -from pypinyin import pinyin -from pypinyin.contrib.tone_convert import to_initials, to_finals_tone - - def text2token( texts: List[str], tokens: str, @@ -38,6 +32,23 @@ def text2token( Return the encoded texts, it is a list of a list of token ids if output_ids is True, or it is a list of list of tokens. """ + try: + import sentencepiece as spm + except ImportError: + print('Please run') + print(' pip install sentencepiece') + print('before you continue') + raise + + try: + from pypinyin import pinyin + from pypinyin.contrib.tone_convert import to_initials, to_finals_tone + except ImportError: + print('Please run') + print(' pip install pypinyin') + print('before you continue') + raise + assert Path(tokens).is_file(), f"File not exists, {tokens}" tokens_table = {} with open(tokens, "r", encoding="utf-8") as f: