Created
November 1, 2018 23:56
-
-
Save topherPedersen/6caf4ea9a925da9a38d8d082ba8606b3 to your computer and use it in GitHub Desktop.
Text to Speech Example in Swift for iOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ViewController.swift | |
| // Text2Speech | |
| // | |
| // Created by apple on 11/1/18. | |
| // Copyright © 2018 thecoderschool. All rights reserved. | |
| // | |
| import UIKit | |
| import AVFoundation | |
| class ViewController: UIViewController { | |
| let avSpeechSynthesizer = AVSpeechSynthesizer() | |
| override func viewDidLoad() { | |
| super.viewDidLoad() | |
| // Do any additional setup after loading the view, typically from a nib. | |
| let phrase = AVSpeechUtterance(string: "I don't brush my teeth, so the dentist eats me.") | |
| avSpeechSynthesizer.speak(phrase) | |
| } | |
| override func didReceiveMemoryWarning() { | |
| super.didReceiveMemoryWarning() | |
| // Dispose of any resources that can be recreated. | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment