a guest Jan 22nd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- var avSpeechSynthesizer = AVSpeechSynthesizer()
- let utterance = AVSpeechUtterance(string: "Hello world")
- utterance.rate = ...
- utterance.pitchMultiplier = ...
- utterance.volume = ...
- utterance.preUtteranceDelay = ...
- utterance.postUtteranceDelay = ...
- // Common 4 operations
- avSpeechSynthesizer.speak(utterance) // Start speech
- avSpeechSynthesizer.pauseSpeaking(at: .immediate) // Pause even in the middle of a vocabulary
- avSpeechSynthesizer.pauseSpeaking(at: .word) // Pause after the current vocabulary has been voiced out completely
- avSpeechSynthesizer.stopSpeaking(at: .immediate) // Similar to the `pauseSpeaking`
- avSpeechSynthesizer.stopSpeaking(at: .word) // Similar to the `pauseSpeaking`
- avSpeechSynthesizer.continueSpeaking() // Resume a paused speech
RAW Paste Data