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()方法来获取系统可用的语音合成声音。

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

相关内容

热门资讯

教程攻略!wepoker是不是... 教程攻略!wepoker是不是有人用挂(辅助挂)竟然真的是有挂(有挂分析辅助app)1、用户打开应用...
今日重大通报!wepoker私... 今日重大通报!wepoker私人局透视方法(辅助挂)竟然有挂(真的有挂辅助方法)进入游戏-大厅左侧-...
总算明白!xpoker辅助器(... 总算明白!xpoker辅助器(辅助挂)都是是有挂(有挂规律辅助技巧)脚本下载中分为三种模型:挂靠谱的...
今日科普!wpk刷入池率脚本(... 今日科普!wpk刷入池率脚本(辅助挂)好像真的是有挂(有挂详细辅助脚本)亲,关键说明,透视脚本安卓赛...
分享认知!xpoker怎么作弊... 分享认知!xpoker怎么作弊(辅助挂)真是是真的有挂(证实有挂辅助方法)1、打开软件启动之后找到中...
终于知道!德普之星app安卓版... 终于知道!德普之星app安卓版破解版(辅助挂)果然有挂(的确有挂辅助器)辅助器是一种具有地方特色的麻...
玩家必看科普!hhpoker有... 玩家必看科普!hhpoker有没有外挂(辅助挂)本来是有挂(有挂神器辅助攻略)1、免费脚本咨询教程、...
交流学习经验!hhpoker脚... 交流学习经验!hhpoker脚本下载(辅助挂)真是是真的有挂(有挂方式辅助软件)1、许多玩家不知道辅...
热点推荐!we poker插件... 热点推荐!we poker插件(辅助挂)都是有挂(有挂功能辅助攻略)1、进入游戏-大厅左侧-新手福利...
终于懂了!wepoker怎么看... 终于懂了!wepoker怎么看牌型(辅助挂)切实有挂(真的有挂辅助工具)1、下载好正确养号方法之后点...