Add Android demo for real-time ASR with non-streaming ASR models. (#2214)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "sherpa-onnx/csrc/offline-recognizer.h"
|
||||
|
||||
#include "sherpa-onnx/csrc/macros.h"
|
||||
#include "sherpa-onnx/csrc/text-utils.h"
|
||||
#include "sherpa-onnx/jni/common.h"
|
||||
|
||||
namespace sherpa_onnx {
|
||||
@@ -327,7 +328,12 @@ Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_newFromAsset(JNIEnv *env,
|
||||
}
|
||||
#endif
|
||||
auto config = sherpa_onnx::GetOfflineConfig(env, _config);
|
||||
SHERPA_ONNX_LOGE("config:\n%s", config.ToString().c_str());
|
||||
|
||||
// logcat truncates long strings, so we split the string into chunks
|
||||
auto str_vec = sherpa_onnx::SplitString(config.ToString(), 128);
|
||||
for (const auto &s : str_vec) {
|
||||
SHERPA_ONNX_LOGE("%s", s.c_str());
|
||||
}
|
||||
|
||||
auto model = new sherpa_onnx::OfflineRecognizer(
|
||||
#if __ANDROID_API__ >= 9
|
||||
@@ -344,7 +350,11 @@ Java_com_k2fsa_sherpa_onnx_OfflineRecognizer_newFromFile(JNIEnv *env,
|
||||
jobject /*obj*/,
|
||||
jobject _config) {
|
||||
auto config = sherpa_onnx::GetOfflineConfig(env, _config);
|
||||
SHERPA_ONNX_LOGE("config:\n%s", config.ToString().c_str());
|
||||
|
||||
auto str_vec = sherpa_onnx::SplitString(config.ToString(), 128);
|
||||
for (const auto &s : str_vec) {
|
||||
SHERPA_ONNX_LOGE("%s", s.c_str());
|
||||
}
|
||||
|
||||
if (!config.Validate()) {
|
||||
SHERPA_ONNX_LOGE("Errors found in config!");
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "sherpa-onnx/csrc/online-recognizer.h"
|
||||
|
||||
#include "sherpa-onnx/csrc/macros.h"
|
||||
#include "sherpa-onnx/csrc/text-utils.h"
|
||||
#include "sherpa-onnx/jni/common.h"
|
||||
|
||||
namespace sherpa_onnx {
|
||||
@@ -295,7 +296,10 @@ Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_newFromAsset(JNIEnv *env,
|
||||
}
|
||||
#endif
|
||||
auto config = sherpa_onnx::GetConfig(env, _config);
|
||||
SHERPA_ONNX_LOGE("config:\n%s", config.ToString().c_str());
|
||||
auto str_vec = sherpa_onnx::SplitString(config.ToString(), 128);
|
||||
for (const auto &s : str_vec) {
|
||||
SHERPA_ONNX_LOGE("%s", s.c_str());
|
||||
}
|
||||
|
||||
auto recognizer = new sherpa_onnx::OnlineRecognizer(
|
||||
#if __ANDROID_API__ >= 9
|
||||
@@ -310,7 +314,11 @@ SHERPA_ONNX_EXTERN_C
|
||||
JNIEXPORT jlong JNICALL Java_com_k2fsa_sherpa_onnx_OnlineRecognizer_newFromFile(
|
||||
JNIEnv *env, jobject /*obj*/, jobject _config) {
|
||||
auto config = sherpa_onnx::GetConfig(env, _config);
|
||||
SHERPA_ONNX_LOGE("config:\n%s", config.ToString().c_str());
|
||||
|
||||
auto str_vec = sherpa_onnx::SplitString(config.ToString(), 128);
|
||||
for (const auto &s : str_vec) {
|
||||
SHERPA_ONNX_LOGE("%s", s.c_str());
|
||||
}
|
||||
|
||||
if (!config.Validate()) {
|
||||
SHERPA_ONNX_LOGE("Errors found in config!");
|
||||
|
||||
Reference in New Issue
Block a user