Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit ebbac99

Browse files
committed
Update TextToSpeech method call for fetching list of available voices
1 parent 226d0af commit ebbac99

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Text to Speech/ViewController.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,23 @@ class ViewController: UIViewController {
8181
}
8282

8383
func loadVoices() {
84-
let failure = { (error: Error) in print(error) }
85-
textToSpeech.getVoices(failure: failure) { voices in
84+
textToSpeech.listVoices { [weak self] (response, error) in
85+
if let error = error {
86+
print(error)
87+
return
88+
}
89+
90+
guard let voices = response?.result?.voices else {
91+
print("Failed to get voices")
92+
return
93+
}
94+
8695
for voice in voices {
87-
self.voices.append(voice.name)
96+
self?.voices.append(voice.name)
8897
}
98+
8999
DispatchQueue.main.async {
90-
self.voicesTableView.reloadData()
100+
self?.voicesTableView.reloadData()
91101
}
92102
}
93103
}

0 commit comments

Comments
 (0)