k2-fsa / sherpa-ncnn

Real-time speech recognition using next-gen Kaldi with ncnn without Internet connection. Support iOS, Android, Raspberry Pi, VisionFive2, LicheePi4A etc.
https://k2-fsa.github.io/sherpa/ncnn/index.html
Apache License 2.0
891 stars 138 forks source link

该语音库安卓端似乎和其他ocr库冲突导致报错,是否有解决方案 #345

Closed 136323000 closed 3 weeks ago

136323000 commented 3 weeks ago

当使用百度飞桨ocr视觉识别库的时候,同时使用sherpa-ncnn 启动的时候会报错:

  A  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 22817 (lczzy.top.lc_ai), pid 22817 (lczzy.top.lc_ai)
2024-06-10 02:06:04.295 26450-26450 DEBUG                   pid-26450                            A  Cmdline: lczzy.top.lc_ai
2024-06-10 02:06:04.295 26450-26450 DEBUG                   pid-26450                            A  pid: 22817, tid: 22817, name: lczzy.top.lc_ai  >>> lczzy.top.lc_ai <<<
2024-06-10 02:06:04.295 26450-26450 DEBUG                   pid-26450                            A        #01 pc 00000000002f9e58  /data/app/~~zMlXSkagEHaA2Xyi2CpDLA==/lczzy.top.lc_ai-Q9G2SU9UnyQRXj-R3vTWWw==/base.apk!libncnn.so (__kmp_abort_process+44) (BuildId: 29feaa5f8604e5097968e710459e96c9ecd44013)
---------------------------- PROCESS ENDED (22817) for package lczzy.top.lc_ai ----------------------------
2024-06-10 02:06:04.462  3471-3866  DollieAdapterService    com.huawei.systemserver              E  notifyActivityState pkg:lczzy.top.lc_ai/lczzy.top.tongsheng.TSTestPage state:19 fg:false mUid:10458

代码:

fun startRecord(){
        if(isRecording){
            stopRecord()
        }
        initModel()
        val ret = initMicrophone()
        if (!ret) {
            Log.e(TAG, "Failed to initialize microphone")
            return
        }
        Log.e(TAG, "state: ${audioRecord?.state}")
        audioRecord!!.startRecording()
        isRecording = true

        lastText = ""
        idx = 0

        recordingThread = thread(true) {
            model.reset(true)

            processSamples()
        }
        Log.e(TAG, "Started recording")
    }

其他代码全部和官方android demo相同

csukuangfj commented 3 weeks ago

ocr 库,有没有用 ncnn?

整个项目里,有几个 ncnn?

csukuangfj commented 3 weeks ago

请看

https://github.com/Tencent/ncnn/issues?q=__kmp_abort_process

csukuangfj commented 3 weeks ago

已在微信群里回复。

解决方法是,禁用 ncnn 里面的 openmp 功能。 由于移动端使用单线程就能识别,禁用 openmp 不会影响速度.