react-native-sherpa-onnx 0.3.6 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -0
- package/README.md +89 -21
- package/SherpaOnnx.podspec +3 -0
- package/THIRD_PARTY_LICENSES/README.md +62 -0
- package/THIRD_PARTY_LICENSES/ffmpeg.txt +502 -0
- package/THIRD_PARTY_LICENSES/libarchive.txt +65 -0
- package/THIRD_PARTY_LICENSES/nvidia_omla.txt +181 -0
- package/THIRD_PARTY_LICENSES/onnxruntime.txt +21 -0
- package/THIRD_PARTY_LICENSES/opus.txt +44 -0
- package/THIRD_PARTY_LICENSES/sherpa-onnx.txt +201 -0
- package/THIRD_PARTY_LICENSES/shine.txt +482 -0
- package/THIRD_PARTY_LICENSES/zstd.txt +30 -0
- package/android/build.gradle +7 -3
- package/android/prebuilt-download.gradle +344 -152
- package/android/prebuilt-versions.gradle +1 -1
- package/android/src/main/assets/model_licenses/asr-models-license-status.csv +409 -0
- package/android/src/main/assets/model_licenses/qnn-asr-models-license-status.csv +695 -0
- package/android/src/main/assets/model_licenses/tts-models-license-status.csv +596 -0
- package/android/src/main/cpp/CMakeLists.txt +28 -10
- package/android/src/main/cpp/jni/archive/sherpa-onnx-archive-helper.cpp +2 -2
- package/android/src/main/cpp/jni/audio/sherpa-onnx-audio-convert-jni.cpp +268 -2
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-model-detect-tts.cpp +6 -2
- package/android/src/main/cpp/jni/model_detect/sherpa-onnx-validate-tts.cpp +4 -2
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxArchiveHelper.kt +40 -10
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxModule.kt +99 -0
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxOnlineSttHelper.kt +4 -1
- package/android/src/main/java/com/sherpaonnx/SherpaOnnxTtsHelper.kt +112 -97
- package/ios/Resources/model_licenses/asr-models-license-status.csv +409 -0
- package/ios/Resources/model_licenses/qnn-asr-models-license-status.csv +695 -0
- package/ios/Resources/model_licenses/tts-models-license-status.csv +596 -0
- package/ios/SherpaOnnx+OnlineSTT.mm +2 -0
- package/ios/SherpaOnnx+PcmLiveStream.mm +2 -29
- package/ios/SherpaOnnx+TTS.mm +178 -20
- package/ios/SherpaOnnx.mm +54 -0
- package/ios/SherpaOnnxAudioConvert.h +10 -0
- package/ios/SherpaOnnxAudioConvert.mm +257 -1
- package/ios/archive/sherpa-onnx-archive-helper.h +3 -0
- package/ios/archive/sherpa-onnx-archive-helper.mm +39 -6
- package/ios/model_detect/sherpa-onnx-model-detect-tts.mm +13 -2
- package/ios/model_detect/sherpa-onnx-validate-tts.mm +4 -2
- package/ios/online_stt/sherpa-onnx-online-stt-wrapper.h +1 -0
- package/ios/online_stt/sherpa-onnx-online-stt-wrapper.mm +4 -0
- package/ios/tts/sherpa-onnx-tts-wrapper.h +37 -0
- package/ios/tts/sherpa-onnx-tts-wrapper.mm +149 -3
- package/lib/module/NativeSherpaOnnx.js.map +1 -1
- package/lib/module/audio/index.js +8 -0
- package/lib/module/audio/index.js.map +1 -1
- package/lib/module/download/ModelDownloadManager.js +10 -929
- package/lib/module/download/ModelDownloadManager.js.map +1 -1
- package/lib/module/download/activeModelOperations.js +26 -0
- package/lib/module/download/activeModelOperations.js.map +1 -0
- package/lib/module/download/background-downloader.d.js +2 -0
- package/lib/module/download/background-downloader.d.js.map +1 -0
- package/lib/module/download/bulkPurge.js +72 -0
- package/lib/module/download/bulkPurge.js.map +1 -0
- package/lib/module/download/checksumPrompt.js +19 -0
- package/lib/module/download/checksumPrompt.js.map +1 -0
- package/lib/module/download/constants.js +7 -0
- package/lib/module/download/constants.js.map +1 -0
- package/lib/module/download/downloadEvents.js +35 -0
- package/lib/module/download/downloadEvents.js.map +1 -0
- package/lib/module/download/downloadTask.js +385 -0
- package/lib/module/download/downloadTask.js.map +1 -0
- package/lib/module/download/ensureModel.js +89 -0
- package/lib/module/download/ensureModel.js.map +1 -0
- package/lib/module/download/index.js +4 -4
- package/lib/module/download/index.js.map +1 -1
- package/lib/module/download/localModels.js +151 -0
- package/lib/module/download/localModels.js.map +1 -0
- package/lib/module/download/modelExtraction.js +174 -0
- package/lib/module/download/modelExtraction.js.map +1 -0
- package/lib/module/download/paths.js +98 -0
- package/lib/module/download/paths.js.map +1 -0
- package/lib/module/download/postDownloadProcessing.js +206 -0
- package/lib/module/download/postDownloadProcessing.js.map +1 -0
- package/lib/module/download/protectedModelKeys.js +31 -0
- package/lib/module/download/protectedModelKeys.js.map +1 -0
- package/lib/module/download/registry.js +267 -0
- package/lib/module/download/registry.js.map +1 -0
- package/lib/module/download/retry.js +59 -0
- package/lib/module/download/retry.js.map +1 -0
- package/lib/module/download/types.js +17 -0
- package/lib/module/download/types.js.map +1 -0
- package/lib/module/download/validation.js +101 -5
- package/lib/module/download/validation.js.map +1 -1
- package/lib/module/{download → extraction}/extractTarBz2.js +3 -1
- package/lib/module/extraction/extractTarBz2.js.map +1 -0
- package/lib/module/{download → extraction}/extractTarZst.js +3 -1
- package/lib/module/extraction/extractTarZst.js.map +1 -0
- package/lib/module/extraction/index.js +3 -4
- package/lib/module/extraction/index.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/licenses.js +63 -0
- package/lib/module/licenses.js.map +1 -0
- package/lib/module/stt/index.js +16 -2
- package/lib/module/stt/index.js.map +1 -1
- package/lib/module/stt/streaming.js +2 -0
- package/lib/module/stt/streaming.js.map +1 -1
- package/lib/module/stt/streamingTypes.js.map +1 -1
- package/lib/module/stt/types.js.map +1 -1
- package/lib/module/tts/index.js +20 -2
- package/lib/module/tts/index.js.map +1 -1
- package/lib/module/tts/streaming.js +4 -0
- package/lib/module/tts/streaming.js.map +1 -1
- package/lib/module/tts/types.js.map +1 -1
- package/lib/module/utils.js +16 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/NativeSherpaOnnx.d.ts +33 -5
- package/lib/typescript/src/NativeSherpaOnnx.d.ts.map +1 -1
- package/lib/typescript/src/audio/index.d.ts +10 -0
- package/lib/typescript/src/audio/index.d.ts.map +1 -1
- package/lib/typescript/src/download/ModelDownloadManager.d.ts +10 -108
- package/lib/typescript/src/download/ModelDownloadManager.d.ts.map +1 -1
- package/lib/typescript/src/download/activeModelOperations.d.ts +6 -0
- package/lib/typescript/src/download/activeModelOperations.d.ts.map +1 -0
- package/lib/typescript/src/download/bulkPurge.d.ts +14 -0
- package/lib/typescript/src/download/bulkPurge.d.ts.map +1 -0
- package/lib/typescript/src/download/checksumPrompt.d.ts +3 -0
- package/lib/typescript/src/download/checksumPrompt.d.ts.map +1 -0
- package/lib/typescript/src/download/constants.d.ts +5 -0
- package/lib/typescript/src/download/constants.d.ts.map +1 -0
- package/lib/typescript/src/download/downloadEvents.d.ts +6 -0
- package/lib/typescript/src/download/downloadEvents.d.ts.map +1 -0
- package/lib/typescript/src/download/downloadTask.d.ts +20 -0
- package/lib/typescript/src/download/downloadTask.d.ts.map +1 -0
- package/lib/typescript/src/download/ensureModel.d.ts +26 -0
- package/lib/typescript/src/download/ensureModel.d.ts.map +1 -0
- package/lib/typescript/src/download/index.d.ts +7 -7
- package/lib/typescript/src/download/index.d.ts.map +1 -1
- package/lib/typescript/src/download/localModels.d.ts +15 -0
- package/lib/typescript/src/download/localModels.d.ts.map +1 -0
- package/lib/typescript/src/download/modelExtraction.d.ts +36 -0
- package/lib/typescript/src/download/modelExtraction.d.ts.map +1 -0
- package/lib/typescript/src/download/paths.d.ts +28 -0
- package/lib/typescript/src/download/paths.d.ts.map +1 -0
- package/lib/typescript/src/download/postDownloadProcessing.d.ts +19 -0
- package/lib/typescript/src/download/postDownloadProcessing.d.ts.map +1 -0
- package/lib/typescript/src/download/protectedModelKeys.d.ts +6 -0
- package/lib/typescript/src/download/protectedModelKeys.d.ts.map +1 -0
- package/lib/typescript/src/download/registry.d.ts +14 -0
- package/lib/typescript/src/download/registry.d.ts.map +1 -0
- package/lib/typescript/src/download/retry.d.ts +15 -0
- package/lib/typescript/src/download/retry.d.ts.map +1 -0
- package/lib/typescript/src/download/types.d.ts +96 -0
- package/lib/typescript/src/download/types.d.ts.map +1 -0
- package/lib/typescript/src/download/validation.d.ts +19 -0
- package/lib/typescript/src/download/validation.d.ts.map +1 -1
- package/lib/typescript/src/extraction/extractTarBz2.d.ts.map +1 -0
- package/lib/typescript/src/extraction/extractTarZst.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/licenses.d.ts +10 -0
- package/lib/typescript/src/licenses.d.ts.map +1 -0
- package/lib/typescript/src/stt/index.d.ts +4 -1
- package/lib/typescript/src/stt/index.d.ts.map +1 -1
- package/lib/typescript/src/stt/streaming.d.ts.map +1 -1
- package/lib/typescript/src/stt/streamingTypes.d.ts +5 -0
- package/lib/typescript/src/stt/streamingTypes.d.ts.map +1 -1
- package/lib/typescript/src/stt/types.d.ts +3 -1
- package/lib/typescript/src/stt/types.d.ts.map +1 -1
- package/lib/typescript/src/tts/index.d.ts +3 -1
- package/lib/typescript/src/tts/index.d.ts.map +1 -1
- package/lib/typescript/src/tts/streaming.d.ts.map +1 -1
- package/lib/typescript/src/tts/types.d.ts +6 -5
- package/lib/typescript/src/tts/types.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +5 -0
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/package.json +6 -1
- package/scripts/{check-model-csvs.sh → ci/check-model-csvs.sh} +9 -2
- package/scripts/ci/collect_all_sherpa_model_streams.sh +101 -0
- package/scripts/ci/collect_one_sherpa_release_stream.sh +189 -0
- package/scripts/ci/sherpa_asr_model_release_streams.json +21 -0
- package/scripts/ci/sherpa_tts_model_release_streams.json +13 -0
- package/scripts/ci/update_model_license_csv.sh +765 -0
- package/scripts/setup-ios-framework.sh +14 -11
- package/scripts/update_commercial_use.js +73 -0
- package/src/NativeSherpaOnnx.ts +36 -5
- package/src/audio/index.ts +20 -0
- package/src/download/ModelDownloadManager.ts +55 -1343
- package/src/download/activeModelOperations.ts +38 -0
- package/src/download/background-downloader.d.ts +43 -0
- package/src/download/bulkPurge.ts +102 -0
- package/src/download/checksumPrompt.ts +25 -0
- package/src/download/constants.ts +5 -0
- package/src/download/downloadEvents.ts +55 -0
- package/src/download/downloadTask.ts +497 -0
- package/src/download/ensureModel.ts +124 -0
- package/src/download/index.ts +19 -4
- package/src/download/localModels.ts +234 -0
- package/src/download/modelExtraction.ts +244 -0
- package/src/download/paths.ts +134 -0
- package/src/download/postDownloadProcessing.ts +292 -0
- package/src/download/protectedModelKeys.ts +30 -0
- package/src/download/registry.ts +404 -0
- package/src/download/retry.ts +76 -0
- package/src/download/types.ts +120 -0
- package/src/download/validation.ts +114 -8
- package/src/{download → extraction}/extractTarBz2.ts +3 -1
- package/src/{download → extraction}/extractTarZst.ts +3 -1
- package/src/extraction/index.ts +3 -7
- package/src/index.tsx +1 -0
- package/src/licenses.ts +100 -0
- package/src/stt/index.ts +20 -2
- package/src/stt/streaming.ts +3 -0
- package/src/stt/streamingTypes.ts +5 -0
- package/src/stt/types.ts +3 -1
- package/src/tts/index.ts +30 -2
- package/src/tts/streaming.ts +10 -0
- package/src/tts/types.ts +6 -5
- package/src/utils.ts +22 -1
- package/third_party/sherpa-onnx-prebuilt/ANDROID_RELEASE_TAG +1 -1
- package/third_party/sherpa-onnx-prebuilt/IOS_RELEASE_TAG +1 -1
- package/android/src/main/cpp/jni/tts/sherpa-onnx-tts-zipvoice-jni.cpp +0 -301
- package/android/src/main/java/com/sherpaonnx/ZipvoiceTtsWrapper.kt +0 -187
- package/lib/module/download/extractTarBz2.js.map +0 -1
- package/lib/module/download/extractTarZst.js.map +0 -1
- package/lib/typescript/src/download/extractTarBz2.d.ts.map +0 -1
- package/lib/typescript/src/download/extractTarZst.d.ts.map +0 -1
- package/scripts/check-qnn-support.sh +0 -78
- /package/lib/typescript/src/{download → extraction}/extractTarBz2.d.ts +0 -0
- /package/lib/typescript/src/{download → extraction}/extractTarZst.d.ts +0 -0
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* sherpa-onnx-tts-zipvoice-jni.cpp
|
|
3
|
-
*
|
|
4
|
-
* Purpose: JNI for Zipvoice TTS using the sherpa-onnx C-API (OfflineTtsZipvoiceModelConfig). The
|
|
5
|
-
* Kotlin TTS API does not expose Zipvoice config, so this native layer is used for Zipvoice-only flows.
|
|
6
|
-
*/
|
|
7
|
-
#include <jni.h>
|
|
8
|
-
#include <cstring>
|
|
9
|
-
#include <android/log.h>
|
|
10
|
-
|
|
11
|
-
#include "sherpa-onnx/c-api/c-api.h"
|
|
12
|
-
|
|
13
|
-
#define LOG_TAG "ZipvoiceTtsJni"
|
|
14
|
-
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
|
|
15
|
-
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
|
|
16
|
-
|
|
17
|
-
namespace {
|
|
18
|
-
|
|
19
|
-
// Helper: get a non-null C string from a jstring (returns "" for null).
|
|
20
|
-
struct JStringGuard {
|
|
21
|
-
JNIEnv* env;
|
|
22
|
-
jstring jstr;
|
|
23
|
-
const char* cstr;
|
|
24
|
-
|
|
25
|
-
JStringGuard(JNIEnv* e, jstring s) : env(e), jstr(s), cstr(nullptr) {
|
|
26
|
-
if (s) cstr = env->GetStringUTFChars(s, nullptr);
|
|
27
|
-
}
|
|
28
|
-
~JStringGuard() {
|
|
29
|
-
if (cstr) env->ReleaseStringUTFChars(jstr, cstr);
|
|
30
|
-
}
|
|
31
|
-
const char* get() const { return cstr ? cstr : ""; }
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// Build a Java float[] + int pair as Object[] { float[], Integer } for returning generated audio.
|
|
35
|
-
jobjectArray buildAudioResult(JNIEnv* env, const float* samples, int32_t n, int32_t sampleRate) {
|
|
36
|
-
jclass objClass = env->FindClass("java/lang/Object");
|
|
37
|
-
if (!objClass) return nullptr;
|
|
38
|
-
|
|
39
|
-
jobjectArray result = env->NewObjectArray(2, objClass, nullptr);
|
|
40
|
-
if (!result) {
|
|
41
|
-
env->DeleteLocalRef(objClass);
|
|
42
|
-
return nullptr;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Element 0: float[] samples
|
|
46
|
-
jfloatArray jsamples = env->NewFloatArray(n);
|
|
47
|
-
if (jsamples && n > 0) {
|
|
48
|
-
env->SetFloatArrayRegion(jsamples, 0, n, samples);
|
|
49
|
-
}
|
|
50
|
-
env->SetObjectArrayElement(result, 0, jsamples);
|
|
51
|
-
if (jsamples) env->DeleteLocalRef(jsamples);
|
|
52
|
-
|
|
53
|
-
// Element 1: Integer sampleRate
|
|
54
|
-
jclass intClass = env->FindClass("java/lang/Integer");
|
|
55
|
-
jmethodID intValueOf = env->GetStaticMethodID(intClass, "valueOf", "(I)Ljava/lang/Integer;");
|
|
56
|
-
jobject jrate = env->CallStaticObjectMethod(intClass, intValueOf, sampleRate);
|
|
57
|
-
env->SetObjectArrayElement(result, 1, jrate);
|
|
58
|
-
env->DeleteLocalRef(intClass);
|
|
59
|
-
if (jrate) env->DeleteLocalRef(jrate);
|
|
60
|
-
|
|
61
|
-
env->DeleteLocalRef(objClass);
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
} // namespace
|
|
66
|
-
|
|
67
|
-
extern "C" {
|
|
68
|
-
|
|
69
|
-
// Create a Zipvoice TTS instance via C-API. Returns the pointer as a jlong (0 on failure).
|
|
70
|
-
JNIEXPORT jlong JNICALL
|
|
71
|
-
Java_com_sherpaonnx_ZipvoiceTtsWrapper_nativeCreate(
|
|
72
|
-
JNIEnv* env, jobject /* this */,
|
|
73
|
-
jstring j_tokens, jstring j_encoder, jstring j_decoder, jstring j_vocoder,
|
|
74
|
-
jstring j_data_dir, jstring j_lexicon,
|
|
75
|
-
jfloat feat_scale, jfloat t_shift, jfloat target_rms, jfloat guidance_scale,
|
|
76
|
-
jint num_threads, jboolean debug,
|
|
77
|
-
jstring j_rule_fsts, jstring j_rule_fars, jint max_num_sentences, jfloat silence_scale,
|
|
78
|
-
jstring j_provider) {
|
|
79
|
-
JStringGuard tokens(env, j_tokens);
|
|
80
|
-
JStringGuard encoder(env, j_encoder);
|
|
81
|
-
JStringGuard decoder(env, j_decoder);
|
|
82
|
-
JStringGuard vocoder(env, j_vocoder);
|
|
83
|
-
JStringGuard dataDir(env, j_data_dir);
|
|
84
|
-
JStringGuard lexicon(env, j_lexicon);
|
|
85
|
-
JStringGuard ruleFsts(env, j_rule_fsts);
|
|
86
|
-
JStringGuard ruleFars(env, j_rule_fars);
|
|
87
|
-
JStringGuard provider(env, j_provider);
|
|
88
|
-
|
|
89
|
-
LOGI("nativeCreate: tokens=%s, encoder=%s, decoder=%s, vocoder=%s, dataDir=%s, lexicon=%s",
|
|
90
|
-
tokens.get(), encoder.get(), decoder.get(), vocoder.get(), dataDir.get(), lexicon.get());
|
|
91
|
-
LOGI("nativeCreate: featScale=%.3f, tShift=%.3f, targetRms=%.3f, guidanceScale=%.3f, threads=%d, debug=%d",
|
|
92
|
-
feat_scale, t_shift, target_rms, guidance_scale, num_threads, debug);
|
|
93
|
-
LOGI("nativeCreate: ruleFsts=%s, ruleFars=%s, maxNumSentences=%d, silenceScale=%.3f, provider=%s",
|
|
94
|
-
ruleFsts.get(), ruleFars.get(), max_num_sentences, silence_scale, provider.get());
|
|
95
|
-
|
|
96
|
-
SherpaOnnxOfflineTtsConfig config;
|
|
97
|
-
memset(&config, 0, sizeof(config));
|
|
98
|
-
|
|
99
|
-
config.model.zipvoice.tokens = tokens.get();
|
|
100
|
-
config.model.zipvoice.encoder = encoder.get();
|
|
101
|
-
config.model.zipvoice.decoder = decoder.get();
|
|
102
|
-
config.model.zipvoice.vocoder = vocoder.get();
|
|
103
|
-
config.model.zipvoice.data_dir = dataDir.get();
|
|
104
|
-
config.model.zipvoice.lexicon = lexicon.get();
|
|
105
|
-
config.model.zipvoice.feat_scale = feat_scale;
|
|
106
|
-
config.model.zipvoice.t_shift = t_shift;
|
|
107
|
-
config.model.zipvoice.target_rms = target_rms;
|
|
108
|
-
config.model.zipvoice.guidance_scale = guidance_scale;
|
|
109
|
-
|
|
110
|
-
config.model.num_threads = num_threads;
|
|
111
|
-
config.model.debug = debug ? 1 : 0;
|
|
112
|
-
config.model.provider = (provider.get() && *provider.get()) ? provider.get() : "cpu";
|
|
113
|
-
|
|
114
|
-
config.rule_fsts = ruleFsts.get();
|
|
115
|
-
config.rule_fars = ruleFars.get();
|
|
116
|
-
config.max_num_sentences = max_num_sentences;
|
|
117
|
-
config.silence_scale = silence_scale;
|
|
118
|
-
|
|
119
|
-
const SherpaOnnxOfflineTts* tts = SherpaOnnxCreateOfflineTts(&config);
|
|
120
|
-
if (!tts) {
|
|
121
|
-
LOGE("nativeCreate: SherpaOnnxCreateOfflineTts returned null");
|
|
122
|
-
return 0;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
LOGI("nativeCreate: success, sampleRate=%d, numSpeakers=%d",
|
|
126
|
-
SherpaOnnxOfflineTtsSampleRate(tts), SherpaOnnxOfflineTtsNumSpeakers(tts));
|
|
127
|
-
|
|
128
|
-
return reinterpret_cast<jlong>(tts);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Destroy a Zipvoice TTS instance.
|
|
132
|
-
JNIEXPORT void JNICALL
|
|
133
|
-
Java_com_sherpaonnx_ZipvoiceTtsWrapper_nativeDestroy(
|
|
134
|
-
JNIEnv* /* env */, jobject /* this */, jlong ptr) {
|
|
135
|
-
auto* tts = reinterpret_cast<const SherpaOnnxOfflineTts*>(ptr);
|
|
136
|
-
if (tts) {
|
|
137
|
-
SherpaOnnxDestroyOfflineTts(tts);
|
|
138
|
-
LOGI("nativeDestroy: released");
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// Get the sample rate of the Zipvoice TTS model.
|
|
143
|
-
JNIEXPORT jint JNICALL
|
|
144
|
-
Java_com_sherpaonnx_ZipvoiceTtsWrapper_nativeGetSampleRate(
|
|
145
|
-
JNIEnv* /* env */, jobject /* this */, jlong ptr) {
|
|
146
|
-
auto* tts = reinterpret_cast<const SherpaOnnxOfflineTts*>(ptr);
|
|
147
|
-
return tts ? SherpaOnnxOfflineTtsSampleRate(tts) : 0;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// Get the number of speakers of the Zipvoice TTS model.
|
|
151
|
-
JNIEXPORT jint JNICALL
|
|
152
|
-
Java_com_sherpaonnx_ZipvoiceTtsWrapper_nativeGetNumSpeakers(
|
|
153
|
-
JNIEnv* /* env */, jobject /* this */, jlong ptr) {
|
|
154
|
-
auto* tts = reinterpret_cast<const SherpaOnnxOfflineTts*>(ptr);
|
|
155
|
-
return tts ? SherpaOnnxOfflineTtsNumSpeakers(tts) : 0;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Generate audio (non-zero-shot). Returns Object[] { float[], Integer }.
|
|
159
|
-
JNIEXPORT jobjectArray JNICALL
|
|
160
|
-
Java_com_sherpaonnx_ZipvoiceTtsWrapper_nativeGenerate(
|
|
161
|
-
JNIEnv* env, jobject /* this */,
|
|
162
|
-
jlong ptr, jstring j_text, jint sid, jfloat speed) {
|
|
163
|
-
auto* tts = reinterpret_cast<const SherpaOnnxOfflineTts*>(ptr);
|
|
164
|
-
if (!tts) {
|
|
165
|
-
LOGE("nativeGenerate: tts pointer is null");
|
|
166
|
-
return nullptr;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
JStringGuard text(env, j_text);
|
|
170
|
-
LOGI("nativeGenerate: text=%s, sid=%d, speed=%.2f", text.get(), sid, speed);
|
|
171
|
-
|
|
172
|
-
const SherpaOnnxGeneratedAudio* audio =
|
|
173
|
-
SherpaOnnxOfflineTtsGenerate(tts, text.get(), sid, speed);
|
|
174
|
-
if (!audio) {
|
|
175
|
-
LOGE("nativeGenerate: SherpaOnnxOfflineTtsGenerate returned null");
|
|
176
|
-
return nullptr;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
LOGI("nativeGenerate: got %d samples at %d Hz", audio->n, audio->sample_rate);
|
|
180
|
-
jobjectArray result = buildAudioResult(env, audio->samples, audio->n, audio->sample_rate);
|
|
181
|
-
|
|
182
|
-
SherpaOnnxDestroyOfflineTtsGeneratedAudio(audio);
|
|
183
|
-
return result;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Generate audio with callback for streaming. Returns Object[] { float[], Integer } for the
|
|
187
|
-
// final concatenated audio. The callback is invoked per chunk.
|
|
188
|
-
JNIEXPORT jobjectArray JNICALL
|
|
189
|
-
Java_com_sherpaonnx_ZipvoiceTtsWrapper_nativeGenerateWithCallback(
|
|
190
|
-
JNIEnv* env, jobject thiz,
|
|
191
|
-
jlong ptr, jstring j_text, jint sid, jfloat speed) {
|
|
192
|
-
auto* tts = reinterpret_cast<const SherpaOnnxOfflineTts*>(ptr);
|
|
193
|
-
if (!tts) {
|
|
194
|
-
LOGE("nativeGenerateWithCallback: tts pointer is null");
|
|
195
|
-
return nullptr;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
JStringGuard text(env, j_text);
|
|
199
|
-
|
|
200
|
-
// We use the progress callback variant to get chunks.
|
|
201
|
-
// The JNI environment and `thiz` are stored in a struct passed through void* arg.
|
|
202
|
-
struct CallbackCtx {
|
|
203
|
-
JNIEnv* env;
|
|
204
|
-
jobject thiz;
|
|
205
|
-
jmethodID onChunkId;
|
|
206
|
-
bool cancelled;
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
jclass cls = env->GetObjectClass(thiz);
|
|
210
|
-
jmethodID onChunkId = env->GetMethodID(cls, "onNativeChunk", "([FI)Z");
|
|
211
|
-
env->DeleteLocalRef(cls);
|
|
212
|
-
if (!onChunkId) {
|
|
213
|
-
LOGE("nativeGenerateWithCallback: onNativeChunk method not found");
|
|
214
|
-
return nullptr;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
CallbackCtx ctx{env, thiz, onChunkId, false};
|
|
218
|
-
|
|
219
|
-
auto callback = [](const float* samples, int32_t n, float /* progress */, void* arg) -> int32_t {
|
|
220
|
-
auto* c = static_cast<CallbackCtx*>(arg);
|
|
221
|
-
if (c->cancelled) return 0;
|
|
222
|
-
|
|
223
|
-
jfloatArray chunk = c->env->NewFloatArray(n);
|
|
224
|
-
if (chunk && n > 0) {
|
|
225
|
-
c->env->SetFloatArrayRegion(chunk, 0, n, samples);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Call Java: boolean onNativeChunk(float[] samples, int n)
|
|
229
|
-
jboolean cont = c->env->CallBooleanMethod(c->thiz, c->onChunkId, chunk, n);
|
|
230
|
-
if (chunk) c->env->DeleteLocalRef(chunk);
|
|
231
|
-
|
|
232
|
-
if (!cont) {
|
|
233
|
-
c->cancelled = true;
|
|
234
|
-
return 0;
|
|
235
|
-
}
|
|
236
|
-
return 1;
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
const SherpaOnnxGeneratedAudio* audio =
|
|
240
|
-
SherpaOnnxOfflineTtsGenerateWithProgressCallbackWithArg(
|
|
241
|
-
tts, text.get(), sid, speed, callback, &ctx);
|
|
242
|
-
|
|
243
|
-
if (!audio) {
|
|
244
|
-
LOGE("nativeGenerateWithCallback: generate returned null");
|
|
245
|
-
return nullptr;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
jobjectArray result = buildAudioResult(env, audio->samples, audio->n, audio->sample_rate);
|
|
249
|
-
SherpaOnnxDestroyOfflineTtsGeneratedAudio(audio);
|
|
250
|
-
return result;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Zero-shot voice cloning with Zipvoice. Returns Object[] { float[], Integer }.
|
|
254
|
-
JNIEXPORT jobjectArray JNICALL
|
|
255
|
-
Java_com_sherpaonnx_ZipvoiceTtsWrapper_nativeGenerateWithZipvoice(
|
|
256
|
-
JNIEnv* env, jobject /* this */,
|
|
257
|
-
jlong ptr, jstring j_text, jstring j_prompt_text,
|
|
258
|
-
jfloatArray j_prompt_samples, jint prompt_sr,
|
|
259
|
-
jfloat speed, jint num_steps) {
|
|
260
|
-
auto* tts = reinterpret_cast<const SherpaOnnxOfflineTts*>(ptr);
|
|
261
|
-
if (!tts) {
|
|
262
|
-
LOGE("nativeGenerateWithZipvoice: tts pointer is null");
|
|
263
|
-
return nullptr;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
JStringGuard text(env, j_text);
|
|
267
|
-
JStringGuard promptText(env, j_prompt_text);
|
|
268
|
-
|
|
269
|
-
jfloat* promptSamples = nullptr;
|
|
270
|
-
jint nPrompt = 0;
|
|
271
|
-
if (j_prompt_samples) {
|
|
272
|
-
nPrompt = env->GetArrayLength(j_prompt_samples);
|
|
273
|
-
promptSamples = env->GetFloatArrayElements(j_prompt_samples, nullptr);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
LOGI("nativeGenerateWithZipvoice: text=%s, promptLen=%d, promptSr=%d, speed=%.2f, steps=%d",
|
|
277
|
-
text.get(), nPrompt, prompt_sr, speed, num_steps);
|
|
278
|
-
|
|
279
|
-
const SherpaOnnxGeneratedAudio* audio =
|
|
280
|
-
SherpaOnnxOfflineTtsGenerateWithZipvoice(
|
|
281
|
-
tts, text.get(), promptText.get(),
|
|
282
|
-
promptSamples, nPrompt, prompt_sr,
|
|
283
|
-
speed, num_steps);
|
|
284
|
-
|
|
285
|
-
if (promptSamples) {
|
|
286
|
-
env->ReleaseFloatArrayElements(j_prompt_samples, promptSamples, JNI_ABORT);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (!audio) {
|
|
290
|
-
LOGE("nativeGenerateWithZipvoice: returned null");
|
|
291
|
-
return nullptr;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
LOGI("nativeGenerateWithZipvoice: got %d samples at %d Hz", audio->n, audio->sample_rate);
|
|
295
|
-
jobjectArray result = buildAudioResult(env, audio->samples, audio->n, audio->sample_rate);
|
|
296
|
-
|
|
297
|
-
SherpaOnnxDestroyOfflineTtsGeneratedAudio(audio);
|
|
298
|
-
return result;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
} // extern "C"
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
package com.sherpaonnx
|
|
2
|
-
|
|
3
|
-
import android.util.Log
|
|
4
|
-
import com.k2fsa.sherpa.onnx.GeneratedAudio
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Kotlin wrapper for Zipvoice TTS via the sherpa-onnx C-API.
|
|
8
|
-
*
|
|
9
|
-
* The official Kotlin API (OfflineTts / OfflineTtsModelConfig) does not expose
|
|
10
|
-
* OfflineTtsZipvoiceModelConfig. This class bypasses the Kotlin API and calls the
|
|
11
|
-
* C-API directly through JNI methods in libsherpaonnx.so.
|
|
12
|
-
*
|
|
13
|
-
* The public API intentionally mirrors [com.k2fsa.sherpa.onnx.OfflineTts] so that
|
|
14
|
-
* [SherpaOnnxTtsHelper] can dispatch to either engine transparently.
|
|
15
|
-
*/
|
|
16
|
-
internal class ZipvoiceTtsWrapper private constructor(private var ptr: Long) {
|
|
17
|
-
|
|
18
|
-
companion object {
|
|
19
|
-
private const val TAG = "ZipvoiceTts"
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Create a Zipvoice TTS engine.
|
|
23
|
-
*
|
|
24
|
-
* @return a wrapper instance, or `null` if creation failed (check logcat for details).
|
|
25
|
-
*/
|
|
26
|
-
fun create(
|
|
27
|
-
tokens: String,
|
|
28
|
-
encoder: String,
|
|
29
|
-
decoder: String,
|
|
30
|
-
vocoder: String,
|
|
31
|
-
dataDir: String,
|
|
32
|
-
lexicon: String,
|
|
33
|
-
featScale: Float = 0.1f,
|
|
34
|
-
tShift: Float = 0.5f,
|
|
35
|
-
targetRms: Float = 0.1f,
|
|
36
|
-
guidanceScale: Float = 1.0f,
|
|
37
|
-
numThreads: Int = 2,
|
|
38
|
-
debug: Boolean = false,
|
|
39
|
-
ruleFsts: String = "",
|
|
40
|
-
ruleFars: String = "",
|
|
41
|
-
maxNumSentences: Int = 1,
|
|
42
|
-
silenceScale: Float = 0.2f,
|
|
43
|
-
provider: String = "cpu"
|
|
44
|
-
): ZipvoiceTtsWrapper? {
|
|
45
|
-
val p = nativeCreate(
|
|
46
|
-
tokens, encoder, decoder, vocoder, dataDir, lexicon,
|
|
47
|
-
featScale, tShift, targetRms, guidanceScale,
|
|
48
|
-
numThreads, debug,
|
|
49
|
-
ruleFsts, ruleFars, maxNumSentences, silenceScale,
|
|
50
|
-
provider
|
|
51
|
-
)
|
|
52
|
-
if (p == 0L) {
|
|
53
|
-
Log.e(TAG, "nativeCreate returned 0 — failed to create Zipvoice TTS engine")
|
|
54
|
-
return null
|
|
55
|
-
}
|
|
56
|
-
return ZipvoiceTtsWrapper(p)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// JNI native methods (implemented in sherpa-onnx-tts-zipvoice-jni.cpp, loaded via libsherpaonnx)
|
|
60
|
-
@JvmStatic
|
|
61
|
-
private external fun nativeCreate(
|
|
62
|
-
tokens: String, encoder: String, decoder: String, vocoder: String,
|
|
63
|
-
dataDir: String, lexicon: String,
|
|
64
|
-
featScale: Float, tShift: Float, targetRms: Float, guidanceScale: Float,
|
|
65
|
-
numThreads: Int, debug: Boolean,
|
|
66
|
-
ruleFsts: String, ruleFars: String, maxNumSentences: Int, silenceScale: Float,
|
|
67
|
-
provider: String
|
|
68
|
-
): Long
|
|
69
|
-
|
|
70
|
-
@JvmStatic
|
|
71
|
-
private external fun nativeDestroy(ptr: Long)
|
|
72
|
-
|
|
73
|
-
@JvmStatic
|
|
74
|
-
private external fun nativeGetSampleRate(ptr: Long): Int
|
|
75
|
-
|
|
76
|
-
@JvmStatic
|
|
77
|
-
private external fun nativeGetNumSpeakers(ptr: Long): Int
|
|
78
|
-
|
|
79
|
-
@JvmStatic
|
|
80
|
-
private external fun nativeGenerate(ptr: Long, text: String, sid: Int, speed: Float): Array<Any>?
|
|
81
|
-
|
|
82
|
-
@JvmStatic
|
|
83
|
-
private external fun nativeGenerateWithZipvoice(
|
|
84
|
-
ptr: Long, text: String, promptText: String,
|
|
85
|
-
promptSamples: FloatArray, promptSr: Int,
|
|
86
|
-
speed: Float, numSteps: Int
|
|
87
|
-
): Array<Any>?
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Instance method: JNI calls onNativeChunk on this object during generation
|
|
91
|
-
private external fun nativeGenerateWithCallback(ptr: Long, text: String, sid: Int, speed: Float): Array<Any>?
|
|
92
|
-
|
|
93
|
-
fun sampleRate(): Int {
|
|
94
|
-
check(ptr != 0L) { "ZipvoiceTtsWrapper already released" }
|
|
95
|
-
return nativeGetSampleRate(ptr)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
fun numSpeakers(): Int {
|
|
99
|
-
check(ptr != 0L) { "ZipvoiceTtsWrapper already released" }
|
|
100
|
-
return nativeGetNumSpeakers(ptr)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Generate audio from text (non-zero-shot, standard TTS).
|
|
105
|
-
* Mirrors [com.k2fsa.sherpa.onnx.OfflineTts.generate].
|
|
106
|
-
*/
|
|
107
|
-
fun generate(text: String, sid: Int = 0, speed: Float = 1.0f): GeneratedAudio {
|
|
108
|
-
check(ptr != 0L) { "ZipvoiceTtsWrapper already released" }
|
|
109
|
-
val result = nativeGenerate(ptr, text, sid, speed)
|
|
110
|
-
?: throw RuntimeException("Zipvoice TTS generate returned null")
|
|
111
|
-
return parseAudioResult(result)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Generate audio with a per-chunk callback for streaming playback.
|
|
116
|
-
* The [callback] receives each audio chunk; return the chunk size to continue, 0 to cancel.
|
|
117
|
-
*
|
|
118
|
-
* Mirrors the callback-based generate in [com.k2fsa.sherpa.onnx.OfflineTts.generateWithCallback].
|
|
119
|
-
*/
|
|
120
|
-
fun generateWithCallback(
|
|
121
|
-
text: String,
|
|
122
|
-
sid: Int = 0,
|
|
123
|
-
speed: Float = 1.0f,
|
|
124
|
-
callback: (FloatArray) -> Int
|
|
125
|
-
): GeneratedAudio {
|
|
126
|
-
check(ptr != 0L) { "ZipvoiceTtsWrapper already released" }
|
|
127
|
-
this.streamCallback = callback
|
|
128
|
-
val result = nativeGenerateWithCallback(ptr, text, sid, speed)
|
|
129
|
-
?: throw RuntimeException("Zipvoice TTS generateWithCallback returned null")
|
|
130
|
-
this.streamCallback = null
|
|
131
|
-
return parseAudioResult(result)
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Zero-shot voice cloning with a reference prompt.
|
|
136
|
-
*
|
|
137
|
-
* @param text Text to synthesize.
|
|
138
|
-
* @param promptText Transcript of the reference audio.
|
|
139
|
-
* @param promptSamples Reference audio samples (mono, [-1, 1]).
|
|
140
|
-
* @param promptSr Sample rate of [promptSamples].
|
|
141
|
-
* @param speed Speed factor (1.0 = normal).
|
|
142
|
-
* @param numSteps Number of flow-matching diffusion steps.
|
|
143
|
-
*/
|
|
144
|
-
fun generateWithZipvoice(
|
|
145
|
-
text: String,
|
|
146
|
-
promptText: String,
|
|
147
|
-
promptSamples: FloatArray,
|
|
148
|
-
promptSr: Int,
|
|
149
|
-
speed: Float = 1.0f,
|
|
150
|
-
numSteps: Int = 20
|
|
151
|
-
): GeneratedAudio {
|
|
152
|
-
check(ptr != 0L) { "ZipvoiceTtsWrapper already released" }
|
|
153
|
-
val result = nativeGenerateWithZipvoice(ptr, text, promptText, promptSamples, promptSr, speed, numSteps)
|
|
154
|
-
?: throw RuntimeException("Zipvoice TTS generateWithZipvoice returned null")
|
|
155
|
-
return parseAudioResult(result)
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
fun release() {
|
|
159
|
-
if (ptr != 0L) {
|
|
160
|
-
nativeDestroy(ptr)
|
|
161
|
-
ptr = 0L
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// -- Streaming callback bridge --
|
|
166
|
-
// Called from JNI (nativeGenerateWithCallback) via the onNativeChunk method.
|
|
167
|
-
@Volatile
|
|
168
|
-
private var streamCallback: ((FloatArray) -> Int)? = null
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Invoked from C++ callback. Must be public for JNI access but is not part of the public API.
|
|
172
|
-
* @return true to continue generating, false to cancel.
|
|
173
|
-
*/
|
|
174
|
-
@Suppress("unused") // Called from JNI
|
|
175
|
-
fun onNativeChunk(samples: FloatArray, n: Int): Boolean {
|
|
176
|
-
val cb = streamCallback ?: return false
|
|
177
|
-
return cb(samples) != 0
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
// -- Internal helpers --
|
|
181
|
-
|
|
182
|
-
private fun parseAudioResult(result: Array<Any>): GeneratedAudio {
|
|
183
|
-
val samples = result[0] as FloatArray
|
|
184
|
-
val sampleRate = (result[1] as Number).toInt()
|
|
185
|
-
return GeneratedAudio(samples, sampleRate)
|
|
186
|
-
}
|
|
187
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["DeviceEventEmitter","SherpaOnnx","extractTarBz2","sourcePath","targetPath","force","onProgress","signal","subscription","removeAbortListener","aborted","abortError","Error","name","addListener","event","safePercent","Math","max","min","percent","onAbort","cancelExtractTarBz2","addEventListener","removeEventListener","result","success","message","reason","error","test","remove"],"sourceRoot":"../../../src","sources":["download/extractTarBz2.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,OAAOC,UAAU,MAAM,wBAAqB;AAe5C,OAAO,eAAeC,aAAaA,CACjCC,UAAkB,EAClBC,UAAkB,EAClBC,KAAK,GAAG,IAAI,EACZC,UAAkD,EAClDC,MAAoB,EACI;EACxB,IAAIC,YAA2C,GAAG,IAAI;EACtD,IAAIC,mBAAwC,GAAG,IAAI;EAEnD,IAAIF,MAAM,EAAEG,OAAO,EAAE;IACnB,MAAMC,UAAU,GAAG,IAAIC,KAAK,CAAC,oBAAoB,CAAC;IAClDD,UAAU,CAACE,IAAI,GAAG,YAAY;IAC9B,MAAMF,UAAU;EAClB;EAEA,IAAIL,UAAU,EAAE;IACdE,YAAY,GAAGR,kBAAkB,CAACc,WAAW,CAC3C,uBAAuB,EACtBC,KAAqD,IAAK;MACzD;MACA,IAAIA,KAAK,CAACZ,UAAU,IAAI,IAAI,IAAIY,KAAK,CAACZ,UAAU,KAAKA,UAAU,EAAE;QAC/D;MACF;MACA,MAAMa,WAAW,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,GAAG,CAAC,GAAG,EAAEJ,KAAK,CAACK,OAAO,CAAC,CAAC;MAC7Dd,UAAU,CAAC;QAAE,GAAGS,KAAK;QAAEK,OAAO,EAAEJ;MAAY,CAAC,CAAC;IAChD,CACF,CAAC;EACH;EAEA,IAAIT,MAAM,EAAE;IACV,MAAMc,OAAO,GAAGA,CAAA,KAAM;MACpB,IAAI;QACFpB,UAAU,CAACqB,mBAAmB,CAAC,CAAC;MAClC,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ,CAAC;IACDf,MAAM,CAACgB,gBAAgB,CAAC,OAAO,EAAEF,OAAO,CAAC;IACzCZ,mBAAmB,GAAGA,CAAA,KAAMF,MAAM,CAACiB,mBAAmB,CAAC,OAAO,EAAEH,OAAO,CAAC;EAC1E;EAEA,IAAI;IACF,MAAMI,MAAM,GAAG,MAAMxB,UAAU,CAACC,aAAa,CAC3CC,UAAU,EACVC,UAAU,EACVC,KACF,CAAC;IACD,IAAI,CAACoB,MAAM,CAACC,OAAO,EAAE;MACnB,MAAMC,OAAO,GAAGF,MAAM,CAACG,MAAM,IAAI,mBAAmB;MACpD,MAAMC,KAAK,GAAG,IAAIjB,KAAK,CAACe,OAAO,CAAC;MAChC,IAAIpB,MAAM,EAAEG,OAAO,IAAI,SAAS,CAACoB,IAAI,CAACH,OAAO,CAAC,EAAE;QAC9CE,KAAK,CAAChB,IAAI,GAAG,YAAY;MAC3B;MACA,MAAMgB,KAAK;IACb;IACA,OAAOJ,MAAM;EACf,CAAC,SAAS;IACRjB,YAAY,EAAEuB,MAAM,CAAC,CAAC;IACtBtB,mBAAmB,GAAG,CAAC;EACzB;AACF","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["DeviceEventEmitter","SherpaOnnx","extractTarZst","sourcePath","targetPath","force","onProgress","signal","subscription","removeAbortListener","aborted","abortError","Error","name","addListener","event","safePercent","Math","max","min","percent","onAbort","cancelExtractTarZst","addEventListener","removeEventListener","result","success","message","reason","error","test","remove"],"sourceRoot":"../../../src","sources":["download/extractTarZst.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,cAAc;AACjD,OAAOC,UAAU,MAAM,wBAAqB;AAe5C,OAAO,eAAeC,aAAaA,CACjCC,UAAkB,EAClBC,UAAkB,EAClBC,KAAK,GAAG,IAAI,EACZC,UAAkD,EAClDC,MAAoB,EACI;EACxB,IAAIC,YAA2C,GAAG,IAAI;EACtD,IAAIC,mBAAwC,GAAG,IAAI;EAEnD,IAAIF,MAAM,EAAEG,OAAO,EAAE;IACnB,MAAMC,UAAU,GAAG,IAAIC,KAAK,CAAC,oBAAoB,CAAC;IAClDD,UAAU,CAACE,IAAI,GAAG,YAAY;IAC9B,MAAMF,UAAU;EAClB;EAEA,IAAIL,UAAU,EAAE;IACdE,YAAY,GAAGR,kBAAkB,CAACc,WAAW,CAC3C,uBAAuB,EACtBC,KAAqD,IAAK;MACzD,IAAIA,KAAK,CAACZ,UAAU,IAAI,IAAI,IAAIY,KAAK,CAACZ,UAAU,KAAKA,UAAU,EAAE;QAC/D;MACF;MACA,MAAMa,WAAW,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,EAAED,IAAI,CAACE,GAAG,CAAC,GAAG,EAAEJ,KAAK,CAACK,OAAO,CAAC,CAAC;MAC7Dd,UAAU,CAAC;QAAE,GAAGS,KAAK;QAAEK,OAAO,EAAEJ;MAAY,CAAC,CAAC;IAChD,CACF,CAAC;EACH;EAEA,IAAIT,MAAM,EAAE;IACV,MAAMc,OAAO,GAAGA,CAAA,KAAM;MACpB,IAAI;QACFpB,UAAU,CAACqB,mBAAmB,CAAC,CAAC;MAClC,CAAC,CAAC,MAAM;QACN;MAAA;IAEJ,CAAC;IACDf,MAAM,CAACgB,gBAAgB,CAAC,OAAO,EAAEF,OAAO,CAAC;IACzCZ,mBAAmB,GAAGA,CAAA,KAAMF,MAAM,CAACiB,mBAAmB,CAAC,OAAO,EAAEH,OAAO,CAAC;EAC1E;EAEA,IAAI;IACF,MAAMI,MAAM,GAAG,MAAMxB,UAAU,CAACC,aAAa,CAC3CC,UAAU,EACVC,UAAU,EACVC,KACF,CAAC;IACD,IAAI,CAACoB,MAAM,CAACC,OAAO,EAAE;MACnB,MAAMC,OAAO,GAAGF,MAAM,CAACG,MAAM,IAAI,mBAAmB;MACpD,MAAMC,KAAK,GAAG,IAAIjB,KAAK,CAACe,OAAO,CAAC;MAChC,IAAIpB,MAAM,EAAEG,OAAO,IAAI,SAAS,CAACoB,IAAI,CAACH,OAAO,CAAC,EAAE;QAC9CE,KAAK,CAAChB,IAAI,GAAG,YAAY;MAC3B;MACA,MAAMgB,KAAK;IACb;IACA,OAAOJ,MAAM;EACf,CAAC,SAAS;IACRjB,YAAY,EAAEuB,MAAM,CAAC,CAAC;IACtBtB,mBAAmB,GAAG,CAAC;EACzB;AACF","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractTarBz2.d.ts","sourceRoot":"","sources":["../../../../src/download/extractTarBz2.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,KAAK,UAAO,EACZ,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,EAClD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAuDxB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extractTarZst.d.ts","sourceRoot":"","sources":["../../../../src/download/extractTarZst.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,aAAa,CACjC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,KAAK,UAAO,EACZ,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,EAClD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAsDxB"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Check if sherpa-onnx prebuilt libraries were built with Qualcomm QNN (NPU) support.
|
|
3
|
-
# Usage: ./check-qnn-support.sh [path-to-libsherpa-onnx-jni.so]
|
|
4
|
-
# ./check-qnn-support.sh [path-to-directory-containing-libs]
|
|
5
|
-
# If no argument, checks ./build-android-arm64-v8a/install/lib/ and current dir.
|
|
6
|
-
|
|
7
|
-
set -e
|
|
8
|
-
|
|
9
|
-
LIBS_DIR=""
|
|
10
|
-
LIB_FILE=""
|
|
11
|
-
|
|
12
|
-
if [ -n "$1" ]; then
|
|
13
|
-
if [ -d "$1" ]; then
|
|
14
|
-
LIBS_DIR="$1"
|
|
15
|
-
elif [ -f "$1" ]; then
|
|
16
|
-
LIB_FILE="$1"
|
|
17
|
-
else
|
|
18
|
-
echo "Usage: $0 [path-to-libsherpa-onnx-jni.so or path-to-lib-directory]"
|
|
19
|
-
exit 1
|
|
20
|
-
fi
|
|
21
|
-
else
|
|
22
|
-
# Default: repo prebuilt output or current dir
|
|
23
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
24
|
-
REPO_BUILD="$SCRIPT_DIR/../third_party/sherpa-onnx-prebuilt/android/arm64-v8a/lib"
|
|
25
|
-
if [ -d "$REPO_BUILD" ] && [ -f "$REPO_BUILD/libsherpa-onnx-jni.so" ]; then
|
|
26
|
-
LIBS_DIR="$REPO_BUILD"
|
|
27
|
-
else
|
|
28
|
-
LIBS_DIR="."
|
|
29
|
-
fi
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
if [ -z "$LIB_FILE" ] && [ -n "$LIBS_DIR" ]; then
|
|
33
|
-
LIB_FILE="$LIBS_DIR/libsherpa-onnx-jni.so"
|
|
34
|
-
if [ ! -f "$LIB_FILE" ]; then
|
|
35
|
-
LIB_FILE="$LIBS_DIR/libsherpa-onnx-c-api.so"
|
|
36
|
-
fi
|
|
37
|
-
fi
|
|
38
|
-
|
|
39
|
-
if [ ! -f "$LIB_FILE" ]; then
|
|
40
|
-
echo "No library found. Tried: $LIB_FILE"
|
|
41
|
-
echo "Usage: $0 [path-to-libsherpa-onnx-jni.so or path-to-lib-directory]"
|
|
42
|
-
exit 1
|
|
43
|
-
fi
|
|
44
|
-
|
|
45
|
-
echo "Checking: $LIB_FILE"
|
|
46
|
-
echo ""
|
|
47
|
-
|
|
48
|
-
# 1) Dynamic dependencies (QNN build MUST link libQnnHtp.so or similar - this is the authoritative check)
|
|
49
|
-
echo "=== Dynamic dependencies (readelf -d) ==="
|
|
50
|
-
QNN_NEEDED=""
|
|
51
|
-
QNN_NEEDED=$(readelf -d "$LIB_FILE" 2>/dev/null | grep -i NEEDED | grep -i qnn) || true
|
|
52
|
-
if [ -n "$QNN_NEEDED" ]; then
|
|
53
|
-
echo "$QNN_NEEDED"
|
|
54
|
-
echo "-> QNN library in NEEDED list --> built WITH QNN support (can use NPU at runtime)"
|
|
55
|
-
else
|
|
56
|
-
echo "-> No QNN-related library in NEEDED list (no libQnnHtp.so etc.)"
|
|
57
|
-
fi
|
|
58
|
-
echo ""
|
|
59
|
-
|
|
60
|
-
# 2) Dynamic symbols (only relevant if NEEDED has QNN; otherwise often just config/error code)
|
|
61
|
-
echo "=== Dynamic symbols containing 'qnn' ==="
|
|
62
|
-
nm -D "$LIB_FILE" 2>/dev/null | grep -i qnn | head -20 || true
|
|
63
|
-
echo ""
|
|
64
|
-
|
|
65
|
-
# 3) Strings (error messages like 'rebuild with QNN' appear even in non-QNN builds - do not use for verdict)
|
|
66
|
-
echo "=== Strings containing 'qnn' (first 10) ==="
|
|
67
|
-
strings "$LIB_FILE" 2>/dev/null | grep -i qnn | head -10
|
|
68
|
-
echo ""
|
|
69
|
-
|
|
70
|
-
echo "=== Verdict ==="
|
|
71
|
-
if [ -n "$QNN_NEEDED" ]; then
|
|
72
|
-
echo "YES – This library was built WITH QNN support (SHERPA_ONNX_ENABLE_QNN=ON)."
|
|
73
|
-
echo " It can use Qualcomm NPU when libQnnHtp.so etc. are provided at runtime."
|
|
74
|
-
else
|
|
75
|
-
echo "NO – This library was built WITHOUT QNN support (CPU/NNAPI only)."
|
|
76
|
-
echo " Strings/symbols with 'qnn' are from error messages in the code, not from QNN linkage."
|
|
77
|
-
echo " To use Qualcomm NPU, rebuild with: cd third_party/sherpa-onnx-prebuilt && ./build_sherpa_onnx.sh"
|
|
78
|
-
fi
|
|
File without changes
|
|
File without changes
|