April 2015
Intermediate to advanced
556 pages
17h 47m
English
Cocoa includes the class NSSpeechSynthesizer; instances of this class produce speech from text.
In MainWindowController.swift, create an instance of NSSpeechSynthesizer.
class MainWindowController: NSWindowController {
@IBOutlet weak var textField: NSTextField!
@IBOutlet weak var speakButton: NSButton!
@IBOutlet weak var stopButton: NSButton!
let speechSynth = NSSpeechSynthesizer()
override var windowNibName: String {
return "MainWindowController"
}
...
}
The NSSpeechSynthesizer class includes these important methods:
func startSpeakingString(_ text: String!) -> Bool func stopSpeaking()
Modify your action methods to call these methods.
class MainWindowController: NSWindowController { ... override func ...