AVAudioEngine inputNode installTap crash when restarting recording

后端 未结 5 1988
猫巷女王i
猫巷女王i 2020-12-14 18:59

I am implementing Speech Recognition in my app. When I first present the view controller with the speech recognition logic, everything works fine. However, when I try presen

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 19:40

    There are two possible ways to solve this problem.

    1. Check inputFormat.channelCount. It may be throwing the error because the mic is in use in another application or somewhere else you yours.
    if(inputNode.inputFormat(forBus: 0).channelCount == 0){
        NSLog("Not enough available inputs!")
        return
    }
    
    1. Try to reset the audioEngine.
    audioEngine.reset()
    

提交回复
热议问题