【问题标题】:AVSpeechSynthesisVoice crashing in iOS 16 betaAVSpeechSynthesisVoice 在 iOS 16 测试版中崩溃
【发布时间】:2022-11-02 06:07:20
【问题描述】:

在 iOS 16 beta 上,以下代码崩溃:

AVSpeechSynthesisVoice(language: "en-US")!

带有以下错误代码:

Fatal error: Unexpectedly found nil while unwrapping an Optional value

它以前运行良好,我没有看到任何 API 更改。

有谁知道会发生什么?

【问题讨论】:

  • 我会向 Apple 提交错误

标签: ios swift ios16


【解决方案1】:

Apple 似乎错过了向 iOS 16 测试版添加语音库的机会。下面的代码返回 nil。

AVSpeechSynthesisVoice.speechVoices()

哪个应该返回可用声音的列表。我提交了一个错误,你也应该。

【讨论】:

    【解决方案2】:

    我相信您在模拟器中遇到了这种情况,但在实际设备上却没有——对吗?原因是对于 iOS 16,Xcode 模拟器中的设备没有任何内置语音,而它们一直都是这样。

    因此,AVSpeechSynthesisVoice.speechVoices() 返回 []AVSpeechSynthesisVoice(language: "en-US") 返回 nil

    要解决这个问题,只需将一个或多个声音下载到您正在编译的模拟设备。为此,请在设备上转到Settings > Accessibility > Spoken Content > Voices > English,选择一种声音,然后下载。

    【讨论】:

      猜你喜欢
      • 2022-12-20
      • 1970-01-01
      • 2015-01-15
      • 1970-01-01
      • 1970-01-01
      • 2017-10-30
      • 2020-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多