tryolabs / TLSphinx

Swift wrapper around Pocketsphinx
MIT License
155 stars 58 forks source link

CantStartAudioEngine #69

Open mranhtu opened 4 years ago

mranhtu commented 4 years ago

Hello, I got this error when running on swift 5. Please help me.

Error Domain=Runtime Error Code=500 "Start decoding speech failed with error: CantStartAudioEngine(Error Domain=com.apple.coreaudio.avfaudio Code=-10868 "(null)" UserInfo={failed call=err = AUGraphParser::InitializeActiveNodesInInputChain(ThisGraph, *GetInputNode())})" UserInfo={NSLocalizedDescription=Start decoding speech failed with error: CantStartAudioEngine(Error Domain=com.apple.coreaudio.avfaudio Code=-10868 "(null)" UserInfo={failed call=err = AUGraphParser::InitializeActiveNodesInInputChain(ThisGraph, *GetInputNode())})}

luciilucii commented 4 years ago

I'm having the same issue, any updates on this?

BrunoBerisso commented 4 years ago

Maybe it will be more useful if you guys could add more info to the issue? Is hard to track it down to something useful just by looking at the error.

A quick search for the error code here https://www.osstatus.com/search/results?platform=all&framework=all&search=-10868 points to a more clear kAudioUnitErr_FormatNotSupported

Is there anything else you guys could add?

luciilucii commented 4 years ago

sure, for me it's happening randomly when the engine is being started. Tested it with AirPods, headphones, and built-in mic still seems to be random.

hcsaaron commented 3 years ago

I got the same error. How to resolve it?

terminal log: 2020-11-06 17:29:47.760997+0800 TLSphinxExample[16307:1568311] [avae] AVAEInternal.h:109 [AVAudioEngineGraph.mm:1397:Initialize: (err = AUGraphParser::InitializeActiveNodesInInputChain(ThisGraph, GetInputNode())): error -10868 Can't start AVAudioEngine: Error Domain=com.apple.coreaudio.avfaudio Code=-10868 "(null)" UserInfo={failed call=err = AUGraphParser::InitializeActiveNodesInInputChain(ThisGraph, GetInputNode())} error: TLSphinx.DecodeErrors.CantStartAudioEngine(Error Domain=com.apple.coreaudio.avfaudio Code=-10868 "(null)" UserInfo={failed call=err = AUGraphParser::InitializeActiveNodesInInputChain(ThisGraph, *GetInputNode())})

randydalrymple commented 3 years ago

I've been fighting the same problem. However, it appeared only when I upgraded my iPhone from iOS 13 to iOS 14 (TLSphinx still built in Swift 4). I get the exact error hcsaaron shows. To date, I haven't found any guidance in the Apple Developer forums, etc.

randydalrymple commented 3 years ago

(1) Can't Start AudioEngine: I'm still working this issue, since my app requires TLSphinx. I found some guidance in a StackOverflow post regarding AudioKit, another 3rd-party product:

https://stackoverflow.com/questions/58193040/avaudiorecorder-audiokit-issues-ios-13-1-2

It seems that Apple changed the default behavior in iOS 13+, and now we must explicitly set parameters and behaviors.

Here is the change I made to fix that problem. It does not harm TLSphinx running on previous versions of iOS: (add to Decoder.startDecodingSpeech()): //------------------------------ let output = engine.outputNode engine.connect(mixer, to: output, format: input.outputFormat(forBus: 0)) //------------------------------

Apparently, the initial failure (can't start audioengine) is caused by a lack of an output node on the graph. Once I added the output node, audioengine started correctly.

(2) Can't Read Valid Data: However, now I'm receiving silence for the data generated by the tap. Somehow, the problem seems to be related to the format passed to mixer.installTap(). If I pass 'formatIn', then the generated data are all '0'. As an experiment, if I pass 'mixer.outputFormat(forBus: 0)', then the tap generates data, but incorrectly formatted (as expected).

If anyone can make more progress on this, please post.