Click here to Skip to main content
Click here to Skip to main content

ESpeakEngine - Objective-C speech synthesizer

By , 23 Jan 2012
 

Introduction

A few years ago I was looking for some Objective-C framework which would allow to speech text on iOS devices in our project. In that time i did not find any, but only tree plain speech synth libraries written i C - eSpeak, Flite and Festival.

After couple days of research and attempts to integrate those libraries for iOS SDK I choosed eSpeak and Flite as candidates (I was able to successfully customize only eSpeak and Flite in reasonable time, they supports more languages, Google use eSpeek for its translation service…).

In next couple of lines is described first speech synthesizer wrapper - ESpeakEngine.

Background

The ESpeakEngine is Objectice-C static library project containing very light wrapper for eSpeak open source speech synthesizer. It does not add any new features to eSpeak, it only exposes its funcionality as Objective-C class methods and combines this functionality with iOS AVFoundation Framework (to see all available properties of eSpeak synthesizer, please read documentation on its homepage url). It also uses standard delegate pattern by defining ESpeakEngineDelegate.

In static library project also exists a test target which contains simple iPhone app. This sample app has only a one screen with the UITextView for text input and the UIButton to start speech syntesis of an entered text.

Using the code

Usage of the ESpeakEngine is very easy, You have to only add a standard dependency on the ESpeakEngine static library project to Your project (simply drag and drop library project file from Finder to Project Navigator):

Screen_Shot_2012-01-24_at_10.34.07.png

add path to folder eSpeak_1.0/Classes in Target Build Settings: Header Search Paths:

Header_search_paths.png

Link ESpeakEngine binary and AVFundation.Framework:

Linked_binaries.png

and link also ESpeakEngine data folder espeak-data - simply drag and drop this folder from referenced eSpeak.xcodeproj project to parent project (to its any group, i drop it in example project to group ESpeakTest/Supporting Files):

Link_epeak-data_dialog.png

Linked_espeak-data.png

Then import the ESpeakEngine header in class which is holding engine instance:

#import "ESpeakEngine.h"   
In the init or the viewDidLoad method create a new instance of the ESpeakEngine and set all parameters you want (language, volume, gender… etc.):
- (void)viewDidLoad {
    [super viewDidLoad];
    engine = [[ESpeakEngine alloc] init];
    engine.volume = 1;
    [engine setLanguage:@"en"];
} 

And finally bind any button touch event to code which calls the ESpeakEngine a 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 test application is 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

About the Author

Jozef Bozek
CEO bring-it-together s.r.o.
Slovakia Slovakia
Member
Jozef Božek is currently a software engineer at bring-it-together s.r.o. in area of large scale infomation systems and mobile applications development.
He has been developing in C++ nearly full time since 2000, in Java since 2004 and in Objective-C since 2009. He is programming using Java EE SDK, iOS SDK, COM/DCOM, MFC, ATL, STL and so on Smile | :)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
AnswerRe: Are there North American voice available? Female voice is better.memberJozef Bozek24 Apr '12 - 23:14 
Hi
yes there is possibility to change male or female voice - just set it by a property
engine.gender
for example:
[engine setGender:kESpeakEngineGenerFemale];
There is possibility to set language as well:
[engine setLanguage:@"en"];
To find all available languages call method
- (NSArray*)supportedLanguages;
which returns array of supported languages in current version of the espeak library
QuestionCan not run [modified]memberdanjirawat23 Jan '12 - 20:10 
Hi Jozef,
 
Thank you for your contribution. I follow your instructions and found 2 problems.
 
The first problem is Apple Mach-O Linker error. I correct it by open the 'Link Binary with Libraries' and add 'libeSpeak.a' and 'AVFoundation.Framework'.
The error is gone but the second problem is the application is not start in the simulator. It's keep attaching something to the run and it's not starting.
 
Please advice, thanks.
Dan
XCode 4.2
iOS SDK 5.0 GM

modified 24 Jan '12 - 2:22.

AnswerRe: Can not runmemberJozef Bozek23 Jan '12 - 22:33 
Hi danjirawat,
 
i apologize, i forget to state this in article, that also is required linkage to ESpeakEngine o file, AVFoundation Framework and finally you have to add reference to folder "espeak-data". Simply drag and drop this folder in project navigator from linked
eSpeak.xcodeproj
to your parent project.
I soon update the arcticle with this information
 
Jozef
AnswerRe: Can not runmemberdanjirawat24 Jan '12 - 5:44 
Thumbs Up | :thumbsup: Thank you Jozef. I finally able to run it.
GeneralMy vote of 5mvpKanasz Robert18 Jan '12 - 20:56 
Hi Jozef. Interesting article but if I could give you one advice, it would be better if you provide more information about this technology.
 
Regards
Robert
P.S. Len tak dalej Wink | ;)
AnswerRe: My vote of 5memberJozef Bozek18 Jan '12 - 23:19 
Hi Rober, thanks for your interest and vote, in future i plan to extend article with little more information about espeak technology, but it depends on my free time
AnswerRe: My vote of 5mvpKanasz Robert18 Jan '12 - 23:58 
I understand. I have the same problem Smile | :) so many ideas but no time.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 24 Jan 2012
Article Copyright 2012 by Jozef Bozek
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid