Creating a basic text to speech
suggest changeUse speakUtterance: on AVSpeechSynthesizer to speak text. Pass an AVSpeechUtterance that contains the text. Import AVFoundation. This is the Swift 2 name. Swift 3 calls speak(_:).
Objective-C
AVSpeechSynthesizer *speaker = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *speech = [AVSpeechUtterance speechUtteranceWithString:@"Hello World"];
[speaker speakUtterance:speech];
Swift
let speaker = AVSpeechSynthesizer()
let speech = AVSpeechUtterance(string: "Hello World")
speaker.speakUtterance(speech)
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents