So, I'm just trying to use AVSpeechSynthesizer with Swift. I cannot figure out how to set the phrase for AVSpeechUtterance.
@IBAction func buttonSpeakClicked(sender:UIButton) { var mySpeechSynthesizer:AVSpeechSynthesizer = AVSpeechSynthesizer() var myString:String = "This is the phrase to say" var mySpeechUtterance:AVSpeechUtterance = AVSpeechUtterance(string:myString) println("\(mySpeechUtterance.speechString)") println("My string - \(myString)") mySpeechSynthesizer .speakUtterance(mySpeechUtterance) }
First println - Nil
Second println - This is a phrase to say
The documentation says init (string string: String!), But I can't figure out where to put it
ios8 swift xcode6
Shadowdes
source share