Skip to content

Instantly share code, notes, and snippets.

@wizard1066
Created November 1, 2022 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wizard1066/8d1c73fef483f180959ae3a2c4254185 to your computer and use it in GitHub Desktop.
Save wizard1066/8d1c73fef483f180959ae3a2c4254185 to your computer and use it in GitHub Desktop.
class speaking: NSObject, AVSpeechSynthesizerDelegate {
var synth:AVSpeechSynthesizer!
override init() {
super.init()
synth = AVSpeechSynthesizer()
}
func speaker(words:[String]) {
for word in words {
let utterance = AVSpeechUtterance(string: word)
utterance.voice = AVSpeechSynthesisVoice(language: "en-US")
synth.speak(utterance)
synth.delegate = self
}
}
func speechSynthesizer(_ synthesizer: AVSpeechSynthesizer,
didFinish utterance: AVSpeechUtterance) {
print("fini")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment