Making text reader (Siri) in X-Code/swift - Cook Book

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

Disclaimer: Gambar, artikel ataupun video yang ada di web ini terkadang berasal dari berbagai sumber media lain. Hak Cipta sepenuhnya dipegang oleh sumber tersebut. Jika ada masalah terkait hal ini, Anda dapat menghubungi kami disini.

Tidak ada komentar:

Posting Komentar

© Copyright 2017 Tutorial Unity 3D