我尝试在我的应用程序 TTS 中集成,但如果单击按钮,则没有音频输出。这是按钮代码:
struct VocabDetailView: View {
//...
var body: some View {
//...
HStack{
Button("Play") {
readOut(text: "test")
}
}
}
}
//The code from readOut is:
func readOut(text: String) {
let utterance = AVSpeechUtterance(string: text)
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
let synth = AVSpeechSynthesizer()
synth.speak(utterance)
}
Run Code Online (Sandbox Code Playgroud)
每次我单击按钮时,Xcode 的输出字段中都会显示:
2022-11-12 09:53:08.349877+0100 Vocab-learner[2394:64531] [plugin] AddInstanceForFactory: No factory registered for id <CFUUID 0x600000354580> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2022-11-12 09:53:19.528945+0100 Vocab-learner[2394:64592] [catalog] Unable to list voice folder
2022-11-12 09:53:19.539617+0100 Vocab-learner[2394:64592] [catalog] Unable to list voice folder …Run Code Online (Sandbox Code Playgroud)