Synthesizing Speech

Cocoa includes the class NSSpeechSynthesizer; instances of this class produce speech from text.

In MainWindowController.swift, create an instance of NSSpeechSynthesizer.

c​l​a​s​s​ ​M​a​i​n​W​i​n​d​o​w​C​o​n​t​r​o​l​l​e​r​:​ ​N​S​W​i​n​d​o​w​C​o​n​t​r​o​l​l​e​r​ ​{​

 ​ ​ ​ ​@​I​B​O​u​t​l​e​t​ ​w​e​a​k​ ​v​a​r​ ​t​e​x​t​F​i​e​l​d​:​ ​N​S​T​e​x​t​F​i​e​l​d​!​
 ​ ​ ​ ​@​I​B​O​u​t​l​e​t​ ​w​e​a​k​ ​v​a​r​ ​s​p​e​a​k​B​u​t​t​o​n​:​ ​N​S​B​u​t​t​o​n​!​
 ​ ​ ​ ​@​I​B​O​u​t​l​e​t​ ​w​e​a​k​ ​v​a​r​ ​s​t​o​p​B​u​t​t​o​n​:​ ​N​S​B​u​t​t​o​n​!​

 ​ ​ ​ ​l​e​t​ ​s​p​e​e​c​h​S​y​n​t​h​ ​=​ ​N​S​S​p​e​e​c​h​S​y​n​t​h​e​s​i​z​e​r​(​)​ ​ ​ ​ ​o​v​e​r​r​i​d​e​ ​v​a​r​ ​w​i​n​d​o​w​N​i​b​N​a​m​e​:​ ​S​t​r​i​n​g​ ​{​ ​ ​ ​ ​ ​ ​ ​ ​r​e​t​u​r​n​ ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.