My Diary.
to Share my Life Events

How to make app speak in IOS

NewImage

 

We will use same AVSpeechSynthesizer class that availabe on iPhone and iPad. It is very easy to make app speak on iOS. You can make the app to say what ever you want. It is based on siri text to speech technology.  If you want to make your app speak, just add the following code in the ViewController.swift files.

 

//

//  ViewController.swift

//  Text2Speech

//

//  Created by Hafiz on 06/10/2016.

//  Copyright © 2016 HafizRich. All rights reserved.

//

 

import UIKit

import AVFoundation

class ViewController: UIViewController {

 

        override func viewDidLoad() {

        super.viewDidLoad()

            let utterance = AVSpeechUtterance(string: "Hello world")

            utterance.voice = AVSpeechSynthesisVoice(language: "en-GB")

            utterance.rate = 0.1

            

            let synthesizer = AVSpeechSynthesizer()

            synthesizer.speakUtterance(utterance)

    }

 

    override func didReceiveMemoryWarning() {

        super.didReceiveMemoryWarning()

        // Dispose of any resources that can be recreated.

    }

 

 

}

 

 

Admin Admin Author