AVSpeechSynthesisVoice.speechVoices()在iOS16beta中返回空数组。
创始人
2024-11-13 09:00:38
0

在iOS 16 beta中,AVSpeechSynthesisVoice.speechVoices()可能会返回空数组。这是因为Apple在此版本中对AVSpeechSynthesisVoice类进行了更改。

为了解决这个问题,使用以下代码:

if #available(iOS 16.0, *) { let voices = [ AVSpeechSynthesisVoice(identifier: AVSpeechSynthesisVoiceIdentifierAlex), AVSpeechSynthesisVoice(identifier: AVSpeechSynthesisVoiceIdentifierSamantha), AVSpeechSynthesisVoice(identifier: AVSpeechSynthesisVoiceIdentifierVictoria), AVSpeechSynthesisVoice(identifier: AVSpeechSynthesisVoiceIdentifierKaren) ] speechSynthesizer = AVSpeechSynthesizer() speechSynthesizer.delegate = self } else { let voices = AVSpeechSynthesisVoice.speechVoices() speechSynthesizer = AVSpeechSynthesizer() speechSynthesizer.delegate = self }

这样,如果运行在iOS 16 beta或更高版本,则使用该数组中列出的语音合成声音。否则,就使用AVSpeechSynthesisVoice.speechVoices()方法来获取系统可用的语音合成声音。

请注意,以上代码仅为示例。可以根据需要添加更多语音合成声音,并根据需要调整代码。

相关内容

热门资讯

推出新举措!wepokerpl... 推出新举措!wepokerplus开挂(透视)好像是有辅助神器(确实有挂)-哔哩哔哩wepokerp...
做出回应!we-poker正规... 做出回应!we-poker正规吗(透视)本来存在有辅助修改器(有人有挂)-哔哩哔哩1、进入游戏-大厅...
透视黑科技!hh poker辅... 透视黑科技!hh poker辅助器先试用(透视)总是真的有辅助神器(确实有挂)-哔哩哔哩1、hh p...
截至发稿!智星德州插件最新版本... 截至发稿!智星德州插件最新版本更新内容详解(透视)其实存在有辅助软件(果真有挂)-哔哩哔哩一、智星德...
随着!wepoker透视最简单... 随着!wepoker透视最简单三个步骤(透视)本来有辅助修改器(确实有挂)-哔哩哔哩1、玩家可以在w...
截至发稿!pokemomo辅助... 截至发稿!pokemomo辅助工具(透视)好像真的是有辅助平台(有挂技巧)-哔哩哔哩1)pokemo...
这一问题亟待解决!拱趴大菠萝挂... 这一问题亟待解决!拱趴大菠萝挂(透视)确实真的是有辅助app(有挂分享)-哔哩哔哩小薇(辅助器软件下...
透视讲解!hhpoker可以控... 透视讲解!hhpoker可以控制吗(透视)果然是有辅助平台(有挂细节)-哔哩哔哩运hhpoker可以...
于此同时!德州真人透视脚本(透... 于此同时!德州真人透视脚本(透视)果然存在有辅助平台(有挂详情)-哔哩哔哩;1、德州真人透视脚本免费...
出现新变化!sohoo竞技联盟... 出现新变化!sohoo竞技联盟辅助器(透视)本来存在有辅助工具(存在有挂)-哔哩哔哩1、出现新变化!...