iOS 15 - AVSpeechSynthesizerDelegate didCancel not getting called

in iOS 15, on stopSpeaking of AVSpeechSynthesizer, didFinish delegate method getting called instead of didCancel which is working fine in iOS 14 and below version.

  • Can you file a bug with a sample project and paste the feedback ID?

Add a Comment

Replies

Hello, I got the same issue. I paste herebelow the code to reproduce. There are 2 files. When run on iOS 15.5, it will print "from inside didFinish speaking". When run on iOS14.3, it will print ""from inside didCancel" which is the correct behaviour according to Apple doc (https://developer.apple.com/documentation/avfaudio/avspeechsynthesizerdelegate/1619678-speechsynthesizer). Done with Xcode 13.4

1st file------------------------

import UIKit

import AVFoundation

class bugReporting: AVSpeechSynthesizer {

    static var shared = bugReporting()     private override init() {         super.init()         delegate = self     }

    let utterance = AVSpeechUtterance(string: "This is to demo the bug of iOS15 not calling didCancel method when stopSpeaking method is called on synthesizer")

    func forTrial() {         utterance.voice = AVSpeechSynthesisVoice(language: "english")         self.speak(utterance)

        DispatchQueue.main.asyncAfter(deadline: .now() + 5) {

            self.stopSpeaking(at: .immediate)         }     } }

extension bugReporting: AVSpeechSynthesizerDelegate {

    func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didCancel utterance: AVSpeechUtterance) {         print("from inside didCancel")     }

    func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer, didFinish utterance: AVSpeechUtterance) {         print("from inside didFinish speaking")     }

}

--------end of 1st file---------

2nd file------------------

import UIKit

class simpleView: UIViewController {     override func viewDidLoad() {         let speaker = bugReporting.shared         speaker.forTrial()     } }

-----------end of 2nd file