speakUtterance: method of
AVSpeechSynthesizer to convert text to speech. You need to pass an
AVSpeechUtterance object to this method, which contains the text that you want to be spoken.
AVSpeechSynthesizer *speaker = [[AVSpeechSynthesizer alloc] init]; AVSpeechUtterance *speech = [AVSpeechUtterance speechUtteranceWithString:@"Hello World"]; [speaker speakUtterance:speech];
let speaker = AVSpeechSynthesizer() let speech = AVSpeechUtterance(string: "Hello World") speaker.speakUtterance(speech)