'Speech recognition during FaceTime call iOS Swift

For my app I want to build a SharePlay experience that uses the Speech framework. During a FaceTime call I want to perform Speech to text on the users device.

I try to get this work calling

        let audioSession = AVAudioSession.sharedInstance()
        try audioSession.setCategory(.playAndRecord, mode: .measurement, options: .duckOthers)
        try audioSession.setActive(true, options: .notifyOthersOnDeactivation)

But I get an error: The operation couldn’t be completed. (OSStatus error 561017449.)

Which basically means: "The app was not allowed to set the audio category because another app (Phone, etc.) is controlling it."

How can I solve this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source