The app is a simplem demo for the speech recognition:
- Add descriptions to the info.plist
- Check permissions on the app start
- Create audio engine and the speech recognition instances.
- Each time on the start initialize the recognition request and the task.
- Destroy the recognition request and the task in the end (or before the new start).
The app works much better with:
SFSpeechRecognizer? = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))
and
try audioSession.setCategory(.playAndRecord, mode: .spokenAudio, options: [.interruptSpokenAudioAndMixWithOthers])
The last lien fixes the strange error:
2018-12-31 07:13:50.498942+0200 SpeechDemo[6772:2783016] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver)