Skip to content

Instantly share code, notes, and snippets.

@topherPedersen
Created November 1, 2018 23:56
Show Gist options
  • Select an option

  • Save topherPedersen/6caf4ea9a925da9a38d8d082ba8606b3 to your computer and use it in GitHub Desktop.

Select an option

Save topherPedersen/6caf4ea9a925da9a38d8d082ba8606b3 to your computer and use it in GitHub Desktop.
Text to Speech Example in Swift for iOS
//
// 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