Advertisemen
Making text reader (Siri) in X-Code/swift - Cook Book
Simplest way to implement the voice command in iOS 10. There are only five lines of code to make it work other than interface. You can use this technique for macOS as well.
There is nothing much to explain so I just make it without comments.
Copy and paste the code used in this tutorial:
import UIKit
import AVFoundation
class ViewController: UIViewController
{
@IBOutlet weak var inputSpeakText: UITextField!
@IBAction func speakBtn(_ sender: AnyObject)
{
let voice = AVSpeechSynthesisVoice(language: "en-au")
let toSay = AVSpeechUtterance(string : inputSpeakText.text!)
toSay.voice = voice
let spk = AVSpeechSynthesizer( )
spk.speak(toSay)
}
}
Please subscribe and share if this is helpful to you. Thanks
Music from :
"Super Power Cool Dude" Kevin MacLeod (incompetech.com)
Licensed under Creative Commons: By Attribution 3.0 License
http://creativecommons.org/licenses/by/3.0/
Advertisemen
Tidak ada komentar:
Posting Komentar