Reputation: 66455
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?
Upvotes: 1
Views: 701
Reputation: 3277
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.
Upvotes: 3
Reputation: 41
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.
Upvotes: 2