AVFoundation AVSpeechUtterance AVSpeechSynthesizer not working in iOS 16 Beta 4, Beta 5

Anyone experiencing issues with Speech to Text in Beta 4 ? It was working absolutely fine in earlier iOS versions.

       let utterance = AVSpeechUtterance(string: "The quick brown fox jumped over the lazy dog.")

      utterance.voice = AVSpeechSynthesisVoice(language: "en-US")

      utterance.volume = 1

      utterance.rate = 0.1

      let synthesizer = AVSpeechSynthesizer()

      synthesizer.speak(utterance)

Post not yet marked as solved Up vote post of kinjal Down vote post of kinjal
4.7k views
  • Looks like iOS lists up voices that has'n been downloaded.

Add a Comment

Replies

Yeah, I am also experiencing the same issue. Even with current beta 6 it is not working. I am seeing some exception in the logs:

[catalog] Unable to list voice folder.

The required voices are present in the iPhone and working properly in Voice Over and Spoken content. Even the voice API AVSpeechSynthesisVoice.speechVoices() is fetching all the voices, but I am getting above exception at line synthesizer.speak(utterance).

Exact same code is working fine in iOS 15 and lower. It would be helpful if any solution is shared.

I am seeing bugs accross the board on AVSpeech related to iOS 16. Have you found a solution?

Hello, I also have the same issue, iOS 16 Beta 6. Did you find a solution ?

I solved it by declaring the AVSpeechSynthesizer as an instance variable instead of a local variable as above. As soon as an AVSpeechSynthesizer goes out of scope and is deallocated, speech output is stopped. Can you try instead storing the synthesizer as an instance or state variable?

  • Thank you very much, it worked !

  • It worked, thank you

  • omg thank you. This worked for me.

Add a Comment

Hi aakashJ,

could please you post a code example of your solution? Michael

Hi @TheMichael,

Check this

class TTS {

     let synth = AVSpeechSynthesizer()

     func speak() {
          let utterance = AVSpeechUtterance(string: "Hello World")
          utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
          synth.speak(utterance)
     }

}

It does not work for me : [catalog] Unable to list voice folder

I regret to have upgraded to iOS 16 :( I've got a lot of issues, this one is one of many

What would be the solution in Objective C? am already caching the AVSpeechSynthesizer in a static class

I'm having the same or similar problem in some old Objective-C code that has worked for a long time. I'm not getting any errors but the didFinishSpeechUtterance delegate method is never getting called. I queue the utterances and then nothing. Does anyone know if Apple has acknowledged this as a bug in iOS 16?

I was able to get my app to start speaking again on the iOS 16 simulators by downloading a voice. It appears those simulators have no voices loaded by default. Here are the steps (on the simulated device itself):

  • Settings/Accessibility/Spoken Content
  • Must turn on Speak Selection. That will cause a "Voices" button to display. Touch that.
  • Select your language.
  • Pick a voice. Click the download button. Wait.
  • When done, you can back out and turn off Speak Selection on the way if

you want. Turning it on is necessary to be able to select and download a voice.

I don't have access to a real iOS 16 device right now so don't know if it's a problem on the devices or not.

  • This worked for me. The simulator has setting just like an actual device. Once I downloaded a voice it worked fine. The downloaded voice has to match the one requested in the code.

Add a Comment

I'm having the same issue on iOS 16.0 prod.

In my environment, AVSpeechUtterance.pitchMultiplier is applied to AVSpeechSynthesizer, but .rate isn't applied.

  • In my case, I had to set AVSpeechUtterance.prefersAssistiveTechnologySettings to false on iOS16.

    It seems that the attribute was not working in iOS15.x.

Add a Comment

Same issue here running iOS 16.0.2 on a real iPhone 12. In my case though there are only complaints and no real errors.

Same issue. Declaring Speech Synthesizer outside of the view does not solve the problem. " Unable to list voice folder" keeps happening. In both: simulators and real devices


struct ContentView: View {



    /// Text to be read

    @State private var text: String = "Paste the text you want to be read here"



    /// Text synthesizer

    var synthesizer: AVSpeechSynthesizer





    var body: some View {

        VStack {

            TextEditor(text: $text)

                .padding()

            .overlay(

                RoundedRectangle(cornerRadius: 16)

                    .stroke(.black, lineWidth: 2)

            )

            Divider()

            Button(action: {

                read()

            },

                   label: {

                Spacer()

                Image(systemName: "speaker.wave.3.fill")

                    .imageScale(.large)

                    .foregroundColor(.black)

                Text("Read")

                    .fontWeight(.black)

                    .font(.largeTitle)

                    .foregroundColor(.black)

                Spacer()

            })

        }

        .padding()

    }



    func read() {



        let speech = AVSpeechUtterance(string: text)

        speech.voice = AVSpeechSynthesisVoice(language: Locale.preferredLanguages.first)



        synthesizer.speak(speech)



    }

}
  • I was facing the same issue for iOS 16

    do{ try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) try AVAudioSession.sharedInstance().setActive(true) }catch{ print("Fail to enable session") }

    Try adding the above code in viewDidLoad() or in onAppear() if using SwiftUI. It resolved my issue.

Add a Comment

I was facing the same issue for iOS 16.

do{
    try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playback) 
    try AVAudioSession.sharedInstance().setActive(true)
 }
catch
{ print("Fail to enable session") } 

Try adding the above code in viewDidLoad() or in onAppear() if using SwiftUI. It resolved my issue.

Add a Comment