Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Mobile / iPhone

FliteEngine - Objective-C speech synthesizer

0.00/5 (No votes)
21 Jan 2012BSD1 min read 23K   420  
FliteEngine - An Objective-C speech synthesizer.

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:

Objective-C
#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):

Objective-C
- (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:

Objective-C
- (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

  • 2010: Initial version.

License

This article, along with any associated source code and files, is licensed under The BSD License