Skip to content

Instantly share code, notes, and snippets.

@myrickchow32
Created February 2, 2019 04:34
Show Gist options
  • Save myrickchow32/3273288604ea0a379ffb2277c2772508 to your computer and use it in GitHub Desktop.
Save myrickchow32/3273288604ea0a379ffb2277c2772508 to your computer and use it in GitHub Desktop.
func getUtteranceWithDelay(preUtteranceDelayInSecond: Int, postUtteranceDelayInSecond: Int) -> AVSpeechUtterance {
let utterance = AVSpeechUtterance(string: "Hello world")
utterance.preUtteranceDelay = TimeInterval.init(exactly: preUtteranceDelayInSecond)!
utterance.postUtteranceDelay = TimeInterval.init(exactly: postUtteranceDelayInSecond)!
return utterance
}
let avSpeechSynthesizer = AVSpeechSynthesizer()
avSpeechSynthesizer.speak(getUtteranceWithDelay(preUtteranceDelayInSecond: 1, postUtteranceDelayInSecond: 2))
avSpeechSynthesizer.speak(getUtteranceWithDelay(preUtteranceDelayInSecond: 1, postUtteranceDelayInSecond: 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment