【问题标题】:AVSpeechSynthesizer isn't working under ios16 anymoreAVSpeechSynthesizer 不再在 ios16 下工作
【发布时间】:2022-09-23 09:47:03
【问题描述】:

我为我的应用程序编写了一个 text2speech 函数的小函数。该代码在 ios16 之前工作正常。现在我看到以下控制台日志:

022-09-13 18:04:02.274692+0200 Blindzeln_Prototyp[47358:164517] [asset] Failed to get sandbox extensions
2022-09-13 18:04:02.314956+0200 Blindzeln_Prototyp[47358:164517] [catalog] Query for com.apple.MobileAsset.VoiceServicesVocalizerVoice failed: 2
2022-09-13 18:04:02.315688+0200 Blindzeln_Prototyp[47358:164517] [catalog] Unable to list voice folder
2022-09-13 18:04:02.333665+0200 Blindzeln_Prototyp[47358:164517] [catalog] Query for com.apple.MobileAsset.VoiceServices.GryphonVoice failed: 2
2022-09-13 18:04:02.334239+0200 Blindzeln_Prototyp[47358:164517] [catalog] Unable to list voice folder
2022-09-13 18:04:02.338622+0200 Blindzeln_Prototyp[47358:164517] [catalog] Unable to list voice folder
2022-09-13 18:04:02.355732+0200 Blindzeln_Prototyp[47358:164583] [AXTTSCommon] File did not exist at content path: (null) (null). Attempting to fallback to default voice for language: (null)
2022-09-13 18:04:02.420342+0200 Blindzeln_Prototyp[47358:164583] [AXTTSCommon] Error: Unable to speak. No speech service: voice: (null) identifier: (null), language: (null), resource: (null)

这是简单的代码:

import Foundation
import AVFoundation

func sayIt(text2speech: String) {
    let utterance = AVSpeechUtterance(string: String(text2speech))
    utterance.voice = AVSpeechSynthesisVoice(language: \"de-DE\")
    utterance.rate = 0.5
    
    let synthesizer = AVSpeechSynthesizer()
    synthesizer.speak(utterance)
}

任何提示?

    标签: swift avfoundation avspeechsynthesizer


    【解决方案1】:

    尝试移动

    let synthesizer = AVSpeechSynthesizer()
    

    函数之外。这对我有用。

    【讨论】:

      【解决方案2】:

      它对我不起作用 错误信息: [目录] 无法列出语音文件夹

      【讨论】:

        【解决方案3】:

        它对我也不起作用。 错误:无法说话。无语音服务:语音:(null)标识符:(null),语言:(null),资源:(null)

        【讨论】:

        • 这并没有真正回答这个问题。如果您有其他问题,可以点击 进行提问。要在此问题有新答案时收到通知,您可以follow this question。一旦你有足够的reputation,你也可以add a bounty 来引起对这个问题的更多关注。 - From Review
        【解决方案4】:

        我也看到了同样的情况。

        我看到“错误:无法说话。没有语音服务:语音:(null)标识符:(null),语言:(null),资源:(null)”和“错误消息:[目录]无法列出语音文件夹“正如其他响应者所提到的。

        将 AVSpeechSynthesizer 移出该功能也无济于事。

        我们认为这是 Apple 会在后续更新中解决的问题吗?

        【讨论】: