Introduction
This is the second speech synthesizer wrapper as I wrote in my previous article ESpeakEngine.
The following sections describe the Flite speech synthesizer wrapper - FliteEngine.
Background
FliteEngine is an Objective-C static library project containing a very light wrapper for the Flite Open Source speech synthesizer.
It does not add any new features to Flite, it only exposes its functionality as Objective-C class methods and combines this functionality with
the iOS AVFoundation Framework (to see all available properties of the Flite synthesizer, please read the documentation on its homepage
URL). It also uses the standard delegate pattern by defining FliteEngineDelegate
.
Using the code
Usage of the FliteEngine
is very easy. You have to only add a standard dependency on the FliteEngine static library project to your project and add a path
to the folder Flite_1_0/Classes in the Target Build Settings: Header Search Paths.
Then import the FliteEngine
header in the class which is holding the engine instance:
#import "FliteEngine.h"
In the init
or the viewDidLoad
method, create a new instance of the FliteEngine
and set all parameters you want (volume, speed, variance, pitch):
- (void)viewDidLoad {
[super viewDidLoad];
engine = [[FliteEngine alloc] init];
engine.volume = 1;
}
And finally, bind any button's touch event to the code which calls the FliteEngine
speak method:
- (IBAction)speech {
NSString * text = self.textView.text;
[engine speak:text];
}
Points of Interest
No documentation is included in this up-to-date version. Anyhow, the source code is self-explanatory and has altogether only a few hundred lines. Also, the test
application is a good start point to look for more properties.
Any questions will be answered, feel free to contact me.
History