k2-fsa / sherpa-ncnn

Real-time speech recognition and voice activity detection (VAD) using next-gen Kaldi with ncnn without Internet connection. Support iOS, Android, Linux, macOS, Windows, Raspberry Pi, VisionFive2, LicheePi4A etc.
https://k2-fsa.github.io/sherpa/ncnn/index.html
Apache License 2.0
1.08k stars 160 forks source link

Using custom model, Android crash #343

Closed Johe-cqu closed 5 months ago

Johe-cqu commented 5 months ago

Using the model you provided (sherpa-ncnn-streaming-zipformer-zh-14m-2023-02-23-chinese), the apk can run normally. But when I use the model I trained myself, it crashes. BTW: The model I trained myself can generate text successfully when using ./pruned_transducer_stateless7_streaming/streaming-ncnn-decode.py.

Can you tell me where I went wrong?

This is the log I got from logcat.

2024-06-04 16:12:15.557  5518-5518  libc                    com.k2fsa.sherpa.ncnn                A  Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 5518 (fsa.sherpa.ncnn), pid 5518 (fsa.sherpa.ncnn)
2024-06-04 16:12:15.674 13845-13845 DEBUG                   pid-13845                            A  pid: 5518, tid: 5518, name: fsa.sherpa.ncnn  >>> com.k2fsa.sherpa.ncnn <<<
2024-06-04 16:12:15.763 13845-13845 DEBUG                   pid-13845                            A        #00 pc 00000000000330f4  /data/app/~~EcYf7YIeS-QRbNxQ2jZRmw==/com.k2fsa.sherpa.ncnn-FxPkvxDcDQaae11hVf3xYg==/lib/arm64/libsherpa-ncnn-core.so (sherpa_ncnn::GreedySearchDecoder::GetEmptyResult() const+36) (BuildId: a0f98d011401c3dc0de238d2af864d2ab137b045)
2024-06-04 16:12:15.763 13845-13845 DEBUG                   pid-13845                            A        #01 pc 000000000003df94  /data/app/~~EcYf7YIeS-QRbNxQ2jZRmw==/com.k2fsa.sherpa.ncnn-FxPkvxDcDQaae11hVf3xYg==/lib/arm64/libsherpa-ncnn-core.so (sherpa_ncnn::Recognizer::Impl::CreateStream() const+548) (BuildId: a0f98d011401c3dc0de238d2af864d2ab137b045)
2024-06-04 16:12:15.763 13845-13845 DEBUG                   pid-13845                            A        #02 pc 0000000000002c2c  /data/app/~~EcYf7YIeS-QRbNxQ2jZRmw==/com.k2fsa.sherpa.ncnn-FxPkvxDcDQaae11hVf3xYg==/lib/arm64/libsherpa-ncnn-jni.so (Java_com_k2fsa_sherpa_ncnn_SherpaNcnn_newFromAsset+184) (BuildId: cf4bc21817aed6d528bcd0cbc4eaa3bdc998cea4)
2024-06-04 16:12:15.763 13845-13845 DEBUG                   pid-13845                            A        #10 pc 0000000000003c72  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~EcYf7YIeS-QRbNxQ2jZRmw==/com.k2fsa.sherpa.ncnn-FxPkvxDcDQaae11hVf3xYg==/base.apk!classes3.dex] (com.k2fsa.sherpa.ncnn.SherpaNcnn.<init>+26)
2024-06-04 16:12:15.763 13845-13845 DEBUG                   pid-13845                            A        #13 pc 0000000000001d6c  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~EcYf7YIeS-QRbNxQ2jZRmw==/com.k2fsa.sherpa.ncnn-FxPkvxDcDQaae11hVf3xYg==/base.apk!classes3.dex] (com.k2fsa.sherpa.ncnn.MainActivity.initModel+136)
2024-06-04 16:12:15.763 13845-13845 DEBUG                   pid-13845                            A        #16 pc 0000000000001de0  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~EcYf7YIeS-QRbNxQ2jZRmw==/com.k2fsa.sherpa.ncnn-FxPkvxDcDQaae11hVf3xYg==/base.apk!classes3.dex] (com.k2fsa.sherpa.ncnn.MainActivity.onCreate+52)
csukuangfj commented 5 months ago

What is the context size of your model?

Johe-cqu commented 5 months ago

--decode-chunk-len 32 --num-left-chunks 4

csukuangfj commented 5 months ago

I mean, --context-size

Johe-cqu commented 5 months ago

--context-size=2

I get more log,and i can‘t find SherapMetaData in encoder_jit_trace-pnnx.ncnn.param. How to fix it? image

2024-06-04 19:08:34.495 13901-13901 ncnn                    com.k2fsa.sherpa.ncnn                W  Unable to create a model from specified model files.
                                                                                                    Please check: 
                                                                                                      1. If you are using a ConvEmformer/Zipformer/LSTM model, please make sure you have added SherapMetaData to encoder_xxx.ncnn.param (or encoder_xxx.ncnn.int8.param if you are using an int8 model). You need to add it manually after converting the model with pnnx.
                                                                                                      2. (Android) Whether the app requires an int8 model or not
2024-06-04 19:08:34.498 13901-13901 libc                    com.k2fsa.sherpa.ncnn                A  Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 13901 (fsa.sherpa.ncnn), pid 13901 (fsa.sherpa.ncnn)
2024-06-04 19:08:34.627 20481-20481 DEBUG                   pid-20481                            A  pid: 13901, tid: 13901, name: fsa.sherpa.ncnn  >>> com.k2fsa.sherpa.ncnn <<<
2024-06-04 19:08:34.728 20481-20481 DEBUG                   pid-20481                            A        #00 pc 00000000000330f4  /data/app/~~2kd-bxW8As8Y_U_6iRhfCQ==/com.k2fsa.sherpa.ncnn-UY8Jbq6qYwco4o3OO2mbiA==/lib/arm64/libsherpa-ncnn-core.so (sherpa_ncnn::GreedySearchDecoder::GetEmptyResult() const+36) (BuildId: a0f98d011401c3dc0de238d2af864d2ab137b045)
2024-06-04 19:08:34.728 20481-20481 DEBUG                   pid-20481                            A        #01 pc 000000000003df94  /data/app/~~2kd-bxW8As8Y_U_6iRhfCQ==/com.k2fsa.sherpa.ncnn-UY8Jbq6qYwco4o3OO2mbiA==/lib/arm64/libsherpa-ncnn-core.so (sherpa_ncnn::Recognizer::Impl::CreateStream() const+548) (BuildId: a0f98d011401c3dc0de238d2af864d2ab137b045)
2024-06-04 19:08:34.728 20481-20481 DEBUG                   pid-20481                            A        #02 pc 0000000000002c2c  /data/app/~~2kd-bxW8As8Y_U_6iRhfCQ==/com.k2fsa.sherpa.ncnn-UY8Jbq6qYwco4o3OO2mbiA==/lib/arm64/libsherpa-ncnn-jni.so (Java_com_k2fsa_sherpa_ncnn_SherpaNcnn_newFromAsset+184) (BuildId: cf4bc21817aed6d528bcd0cbc4eaa3bdc998cea4)
2024-06-04 19:08:34.728 20481-20481 DEBUG                   pid-20481                            A        #10 pc 0000000000003c50  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~2kd-bxW8As8Y_U_6iRhfCQ==/com.k2fsa.sherpa.ncnn-UY8Jbq6qYwco4o3OO2mbiA==/base.apk!classes3.dex] (com.k2fsa.sherpa.ncnn.SherpaNcnn.<init>)
2024-06-04 19:08:34.728 20481-20481 DEBUG                   pid-20481                            A        #16 pc 0000000000001ce4  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~2kd-bxW8As8Y_U_6iRhfCQ==/com.k2fsa.sherpa.ncnn-UY8Jbq6qYwco4o3OO2mbiA==/base.apk!classes3.dex] (com.k2fsa.sherpa.ncnn.MainActivity.initModel)
2024-06-04 19:08:34.728 20481-20481 DEBUG                   pid-20481                            A        #22 pc 0000000000001dac  [anon:dalvik-classes3.dex extracted in memory from /data/app/~~2kd-bxW8As8Y_U_6iRhfCQ==/com.k2fsa.sherpa.ncnn-UY8Jbq6qYwco4o3OO2mbiA==/base.apk!classes3.dex] (com.k2fsa.sherpa.ncnn.MainActivity.onCreate)
csukuangfj commented 5 months ago

The fix is to.follow.the doc strictly.

Johe-cqu commented 5 months ago

thank you so much. Fix it