avfoundation - 文本到语音 API (AVSpeechSynthesisVoice) 在 iOS 13 GM 中损坏

标签 avfoundation ios13 avspeechsynthesizer avspeechutterance

更新

我在不同的设备上安装了 iOS 13 GM,没有遇到这个问题。所以我不再确定这是否特定于 iOS 13 GM,或者关于我安装它的方式。在第一台设备(iPhone X)上,我进行了升级(通过 iTunes 中的“Option Key + Check for Update Button”)。在第二台设备(iPhone SE)上,我进行了完全恢复。还不确定是什么导致它进入这种状态。

原问题
AVSpeechSynthesisVoice.speechVoices()报告说当我使用 iOS 13 GM 在我的设备上运行它时没有可用的声音。事实上,当我尝试使用 AVSpeechSynthesisVoice(identifier:) 加载语音时它总是返回零。它在模拟器中工作。我不认为这是以前测试版的问题,它似乎适用于 iOS 13.1 beta 2 和 3。

有没有人遇到过这个,并想出了任何解决方法?我没有看到任何有意改变这种行为的文档,所以我怀疑这是一个错误。我打算提交雷达。但这对即将发布的 iOS 13 无济于事。

这种行为可以在新创建的单一 View 项目中重现,以下是微不足道的 viewDidLoad功能添加到包含的 View Controller 。

override func viewDidLoad() {
    super.viewDidLoad()

    let voices = AVSpeechSynthesisVoice.speechVoices()
    print("Voice Count: \(voices.count)")
}

输出很长:
2019-09-11 10:43:09.370992-0400 SpeechTest[1617:412065] Creating client/daemon connection: C591307C-313E-4B5F-91A8-184B7E662819
2019-09-11 10:43:09.396250-0400 SpeechTest[1617:412065] Got the query meta data reply for: com.apple.MobileAsset.MacinTalkVoiceAssets, response: 0
2019-09-11 10:43:09.397519-0400 SpeechTest[1617:412065] Consumed extension
2019-09-11 10:43:09.401982-0400 SpeechTest[1617:412065] Got the query meta data reply for: com.apple.MobileAsset.MacinTalkVoiceAssets, response: 0
Voice Count: 0
2019-09-11 10:43:09.435890-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.445269-0400 SpeechTest[1617:412066] Consumed extension
2019-09-11 10:43:09.468849-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.499573-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.520244-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.GryphonVoice, response: 0
2019-09-11 10:43:09.545243-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.CustomVoice, response: 0
2019-09-11 10:43:09.549941-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.CombinedVocalizerVoices, response: 2
2019-09-11 10:43:09.550075-0400 SpeechTest[1617:412066] [AXTTSCommon] Error running custom voice query XML not present
2019-09-11 10:43:09.569114-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.599459-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.630763-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServicesVocalizerVoice, response: 0
2019-09-11 10:43:09.650161-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.GryphonVoice, response: 0
2019-09-11 10:43:09.666885-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.CustomVoice, response: 0
2019-09-11 10:43:09.671279-0400 SpeechTest[1617:412066] Got the query meta data reply for: com.apple.MobileAsset.VoiceServices.CombinedVocalizerVoices, response: 2
2019-09-11 10:43:09.671412-0400 SpeechTest[1617:412066] [AXTTSCommon] Error running custom voice query XML not present
...

它重复了最后 7 行 39 次,大概对应于它应该知道的 39 个声音。

最佳答案

我有同样的 AVSpeechUtterance 问题,随着时间的推移,它似乎已经在我的设备上自行解决。使用之前崩溃的应用程序或全新安装一段时间后,我不再在 iOS 13 或 13.1 上崩溃。

关于avfoundation - 文本到语音 API (AVSpeechSynthesisVoice) 在 iOS 13 GM 中损坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57891839/

相关文章:

ios - 如何继续播放随机歌曲?

ios - 无法理解我的 spritekit 游戏中的延迟?

ios - 录制一秒钟的视频 Swift?

iOS 13 如何检查用户是否只被授予始终允许位置权限

ios - 应用程序卡在带有 Xcode 11 beta 的 iOS 13 beta 模拟器上,但在带有 Xcode 10 的 iOS 13 beta 模拟器上运行良好

ios - 是否可以使用 avspeechsynthesizer 保存音频?

iOS swift : UIAccessibilitySpeechAttributeIPANotation

iOS:在 AV 视频上绘图,然后将绘图保存在视频文件中

iOS 13 如何在导航栏中隐藏 UISearchController searchBar

ios - AVSpeechSynthesizer - 使用 AVSpeechBoundaryImmediate 时不会停止