From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

Use the speech synthesizer

Use the speech synthesizer

From the course: iOS Development Tips

Use the speech synthesizer

- [Instructor] It's sometimes nice to add a little sound to your applications, and even better to add a voice. Outside SIRI, you can use a cool and simple AV foundation API to make iOS devices talk. Let's learn how to use the speech synthesizer. Download the starter file. I've made an app for you that if you go to the storyboard, you'll find it has a text field and a button. And you'll also notice a segue to a table view which I'm gonna discuss a little later. Go to the view controller dot swift file. And file the speak action here. We're gonna do all of our work in here. And we're gonna need to get a string from the text field. So the following code will get that text if the field actually has a value. So we're gonna do if let speech text equals speaking text, which is the name of my outlet, dot text. Now, you're gonna need two objects, a synthesizer object and a speech utterance. But before you do, make sure, which I do here, you have import AV foundation, because these are AV…

Contents