skip to Main Content

On iOS 16 beta, the following code is crashing:

AVSpeechSynthesisVoice(language: "en-US")!

with the following error code:

Fatal error: Unexpectedly found nil while unwrapping an Optional value

It worked fine before and I’m not seeing any API change.

Does anyone know what could be going on?

2

Answers


  1. It seems like Apple missed to add voice libraries to iOS 16 betas. Below code returns nil.

    AVSpeechSynthesisVoice.speechVoices()
    

    Which should return the list of available voices. I filed a bug, you should also.

    Login or Signup to reply.
  2. I believe you are experiencing this in the simulator, but not on actual devices – correct? The reason is that for iOS 16, the devices in the Xcode simulator do not come with any built-in voices, whereas they always used to.

    As a result, AVSpeechSynthesisVoice.speechVoices() returns [], and AVSpeechSynthesisVoice(language: "en-US") returns nil.

    To solve this, simply download one or more voices to the simulated device you are compiling to. To do that, on the device go to Settings > Accessibility > Spoken Content > Voices > English, select a voice, and download it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search