PR to fix issue with first word missed on iOS on 2nd+ calls to listen… #513
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
iOS does not recognize the first word after calling the .listen() for second time and further, i.e. listen (all good here) -> stop -> listen (missed first word) -> stop -> etc...
If I benchmark the time from try self.audioEngine.start() to the first buffer received in the callback of inputNode?.installTap, there is approx. 175ms, which is sufficient to catch the first word. However on the second+ call to listenForSpeech, the same benchmark results in approx. 850ms, which is more than enough to miss the first word.
After experimenting a bit, I noticed that instantiating a new audioEngine and of course inputNode fixes this issue and we are back on cirka 175ms before receiving the first buffer on second+ calls.