The current version of iOS brings some changes to multimedia playback and functionality, especially the AVFoundation framework. In this chapter, we will have a look at those additions and some of the changes.
Make sure that you have imported the AVFoundation framework in your app before running the code in this chapter.
You want to use the default Siri Alex voice on a device to speak some text.
AVSpeechSynthesisVoice with the
identifier initializer and pass the value of
AVSpeechSynthesisVoiceIdentifierAlex to it.
Let’s create an example out of this. Create your UI so that it looks like Figure 12-1. Place a text view on the screen and a bar button item in your navigation bar. When the button is pressed, you will ask Siri to speak out the text inside the text view.
I’ve linked the text view to a property in my view controller called
When the Read button is pressed, check first whether Alex is available:
"Alex is not available"
AVSpeechSynthesisVoice have properties such as
name. The identifier can be used later to ...