0
我想知道如何让AVSpeechSynthesisVoice从按钮读取文本。我对Swift很陌生。不过,我有以下的阅读从一个字符串:AVSpeechSynthesisVoice从按钮标签读取
@IBAction func btnOption1Audio(sender: UIButton)
{
myUtterance = AVSpeechUtterance(string: "Hola")
myUtterance.rate = 1
synth.speakUtterance(myUtterance)
myUtterance.voice = AVSpeechSynthesisVoice(language: "es-ES")
}
但是,当我将其更改为这样的事情(阅读按钮上的文字),它不会工作。我相信这只是一个语法问题,但:
@IBAction func btnOption1Audio(sender: UIButton)
{
myUtterance = AVSpeechUtterance(string: btnOption1Tap.titlelabel.text)
myUtterance.rate = 1
synth.speakUtterance(myUtterance)
myUtterance.voice = AVSpeechSynthesisVoice(language: "es-ES")
}
我要去哪里错了?
在此先感谢
感谢您的详细回答,这是非常赞赏。我现在要试一试。我对swift非常陌生,因此需要付出很多努力:) – BCLtd
我的工作得到了您的帮助。谢谢! – BCLtd