31 Mar

Create a Text to Speech App With Swift

With the release of iOS 7, Apple introduced a text to speech API that allows developers to add text to speech functionality to an application in a quick and easy way. This can be useful when adding an accessibility layer to an application or to include it as a feature in a learning game. In this tutorial, you’ll learn how to implement such a feature using Swift. Note:  remember to add  before “AVFoundation framework” to your project

Swift Example:

import AVFoundation

let synthvoice = AVSpeechSynthesizer()
var mySentence = AVSpeechUtterance(string: “Caricamento dati in corso”)
mySentence.rate = 0.4


#import <AVFoundation/AVFoundation.h>

AVSpeechSynthesizer *synthvoice = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *mySentence = [[AVSpeechUtterance alloc] initWithString:@”Caricamento dati in corso”];
mySentence.rate = 0.4;
[synthvoice speakUtterance:mySentence];