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
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 | :)
Follow on   Twitter   Google+

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   
QuestionCan't read data file:memberAnandhakumar Palanisamy20-Feb-13 0:10 
Hi,
i am following step by step method what you explained but i am getting this error.
 
/Users/Library/Application Support/iPhone Simulator/6.1/Applications/34FB8DDF-2279-4E56-A827-A9AE97D7C09A/ESpeakTest.app/espeak-data/phontab
 
Failed to load espeak-data
 
Please help to solve this issue
GeneralMy vote of 3memberLinasses11-Jan-13 0:32 
Does not seem to work with arm7 devices.
Questionjust awful speech!memberYoeluk15-Dec-12 10:00 
Nice try but there is no way this or Flite will please any user out there. Not worth adding to an app that you are planning submitting to the App Store. Unfortunately we just have to wait :(
AnswerRe: just awful speech!memberJozef Bozek15-Dec-12 12:01 
Hi, just for your information - we are using this library in our application Twitran - you can find it on the App Store.
GeneralRe: just awful speech!memberYoeluk15-Dec-12 17:18 
I'm sorry Jozef I didn't mean that personally. I take back "nice try". I realised that it was out of my frustration looking for a text-to-speech that sounds natural. I downloaded twitran and can not find where is the button to put the text-to-speech to the test. However I did implemented ESpeakEngine following your guide and some other minor changes because the errors that you get on Xcode 4.5.2 with the current guide. The result was a computerised voice though. This might be okay in a context like twitran but totally inadequate if the purpose is to read instructions to a native English speaker in English. If you think that I'm wrong (I really want to be wrong!) tell me where is the text-to-speech on twitran. I'll buy it if necessary and give you a five stars review if the voice isn't computerised and if so hopefully you can tell me how to make it sound natural in my implementation.
 
In any case, thanks a lot for sharing what you've made Smile | :)
AnswerRe: just awful speech!memberJozef Bozek6-Feb-13 22:28 
Hi, it's ok, i did not take it personally. I took the eSpeak library as is (as i am not expert in TTS) because for our needs computerized voice was quite suitable (in twitran, there is a speech button in a tweet detail view where it is shown only if you select translation button). Anyway, as i know, google is using eSpeak library as its TTS engine in translate project and resulting voice is quite good. So i think that there is an option to setup the eSpeak properties to get better voice quality - but i did not examine it deeper.
QuestionEspeak Text to speechmemberammadandamu2-Dec-12 6:37 
I am using espeak text to speech into my one of application and i want to submit that application to apple store does google.espeak allows to use the espeak libraries in paid applications ? and how i can change voice from male to female and also i want to insert more languages any suggetions
Regards Ammad.Emy
AnswerRe: Espeak Text to speechmemberJozef Bozek15-Dec-12 11:50 
Hi, yes you can use ESpeakEngine library in any paid application. To set female voice - please see my previous comment for bilal78699.
Regards
Jozef
QuestionUsing different accentsmemberpluto9999-Oct-12 13:57 
I've tried to set the language for this using the setLanguage command, eg:
[engine setLanguage:@"en-sc"];   // Should give me scottish accent
 
But try as I might I always seem to get Stephen Hawking (much as I like the guy!)
Can you please give an example of setting the accent/language to something else?
AnswerRe: Using different accentsmemberJozef Bozek15-Dec-12 11:53 
Hi, you found a bug - i just fixed it. To get current version of the ESpeakEngine library, please visit my google code repository - http://code.google.com/p/espeak-engine/[^]
QuestionEspeak Iphone Project How to change male voice ?memberbilal7869918-Sep-12 23:44 
Hello I m a student from Uet-taxila and i am working on TTS.I am New to Iphone Developing. I want change voice of male to female voice just like voice in iphone siri waiting for your Response .....
AnswerRe: Espeak Iphone Project How to change male voice ?memberJozef Bozek25-Oct-12 4:25 
Hallo,
 
sorry for a late response - a lot of work. Changing between the male or female voice is easy - just call setGender method:
engine setGender:kESpeakEngineGenerMale
or
engine setGender:kESpeakEngineGenerFemale

QuestionI follow your instructions and found 2 problemsmemberamielreyes033-Jul-12 21:25 
ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Library/Frameworks/SenTestingKit.framework/SenTestingKit, missing required architecture armv7 in file
ld: warning: ignoring file /Users/romeoflauta/Library/Developer/Xcode/DerivedData/ESpeakTest-dsxgdbasmtyykbcidzyvfaxvvgxb/Build/Products/Debug-iphoneos/libeSpeak.a, file was built for archive which is not the architecture being linked (armv7)
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ESpeakEngine", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
AnswerRe: I follow your instructions and found 2 problemsmemberJozef Bozek15-Dec-12 11:57 
Hi, it was a problem with armv7 architecture - i just updated project settings (i successfully built and tested it on iPhone 5 with iOS 5.1). To get current version of the ESpeakEngine library, please visit my google code repository - http://code.google.com/p/espeak-engine/[^]
GeneralRe: I follow your instructions and found 2 problemsmemberLinasses10-Jan-13 6:56 
I too am having an issue with the arm7 version of the library.
I am using the latest version, downloaded today 10 Jan 2013.
Getting this linker report:
 
ld: warning: ignoring file /Users/linasses/Library/Developer/Xcode/DerivedData/ESpeakTest-gwthgoszenaqdzazfrpfugqfjhbh/Build/Products/Debug-iphoneos/libeSpeak.a, file was built for archive which is not the architecture being linked (armv7): /Users/linasses/Library/Developer/Xcode/DerivedData/ESpeakTest-gwthgoszenaqdzazfrpfugqfjhbh/Build/Products/Debug-iphoneos/libeSpeak.a
Undefined symbols for architecture armv7:
"_OBJC_CLASS_$_ESpeakEngine", referenced from:
objc-class-ref in FliteEngineTestViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

 
and:
 
ld: warning: ignoring file /Users/linasses/Library/Developer/Xcode/DerivedData/ESpeakTest-gwthgoszenaqdzazfrpfugqfjhbh/Build/Products/Debug-iphoneos/libeSpeak.a, file was built for archive which is not the architecture being linked (armv7): /Users/linasses/Library/Developer/Xcode/DerivedData/ESpeakTest-gwthgoszenaqdzazfrpfugqfjhbh/Build/Products/Debug-iphoneos/libeSpeak.a
 
Any ideas about how to fix it?
 
Also, you say the you have built it for iPhone5 on iOS 5.1, I thought that iPhone5 was 6.0 and greater.
Also, which version of Xcode did you use. (I am trying 4.4.0).
 
Thanks
Linasses
AnswerRe: I follow your instructions and found 2 problemsmemberJozef Bozek6-Feb-13 22:05 
Hi Linasses,
 
yes, you are right - i have built the project for iPhone5 on iOS 6.01 using Xcode 4.5.2.
To solve Your build problem please ensure You setup in linked eSpeak.xcodeproj:
 
Build Settings -> Architectures property to Standard (armv7, armv7s) $(ARCHS_STANDARD_32_BIT)
Build Settings -> Base SDK property to Latest iOS
 
And also ensure if You are linking the ESpeakEngine static library libeSpeak.a for same build Destination as main application e.g. iPhone 6.0 Simulator. Each time you change the build Destination You have to link the ESpeakEngine static library libeSpeak.a which is built for same Destination. You can use a tool lipo, it can combine multiple static library files into single file.
QuestionPlease help me Device error-membernielmabahohehehe1-Jul-12 14:50 
no such file or directory: '/Users/admin/Library/Developer/Xcode/DerivedData/ESpeakTest-acdpkragszypxwephcohdkuljrts/Build/Products/Debug-iphoneos/libeSpeak.a'
 

how to link libeSpeak.a static library to your target destination - iOS Device
 
give a step by step tutorial to link a libespeak tnx
AnswerRe: Please help me Device error-memberJozef Bozek2-Jul-12 6:10 
Hi, as you can see on a third screenshot, select your target then "Build Phases" and there select section "Link Binary With Libraries". Click on "+" button in "Link Binary With Libraries" sectoin an then "Add other..." (at the bottom left) - it shows file dialog where you can select libeSpeak.a binary.
QuestionProblem deploying to devicememberMember 386931717-May-12 6:12 
Hi!
 
I'm having a problem getting this to compile while trying to build to a device. I've followed everything outlined in the tutorial but for some reason I get the following when it builds.
 
arm-apple-darwin10-llvm-gcc-4.2: /Users/user/Library/Developer/Xcode/DerivedData/TestApp-efxvwtzxfgzskwgjjmffnudkaovh/Build/Products/Debug-iphoneos/libeSpeak.a: No such file or directory
 
I have a feeling this may be related to linking the binary to the target. When I click the + next to 'Link Binary With Libraries' and select 'libeSpeak.a' from Workspace it appears but it's marked in red which I believe indicates it can't find it or there's a problem?!
 
I can't figure out where am I going wrong?
 
Thanks in advance!
AnswerRe: Problem deploying to devicememberJozef Bozek22-May-12 5:00 
hi,
yes , it looks like you do not have linked binary to target build destination. If a file is marked in red then it does not exists on file system
QuestionCant get working on device.memberjayy6615-May-12 17:43 
It works great on the simulator but when I try running it on an iPhone I get:
Apple Mach-O Linker Error
no such file or directory: '/Users/Jason/Library/Developer/Xcode/DerivedData/TestAppeSpeak-heggxnbxqfhnnrggxnypgjttdrcp/Build/Products/Debug-iphoneos/libeSpeak.a'
 
I followed all the instructions.
 
What am I doing wrong?
AnswerRe: Cant get working on device.memberJozef Bozek15-May-12 21:37 
hi, it looks like you did not link libeSpeak.a static library to your target destination - iOS Device
GeneralRe: Cant get working on device.memberjayy6616-May-12 16:03 
How would I do that?
GeneralRe: Cant get working on device.memberjayy6616-May-12 16:33 
Never mind I figured it out. I added it to the target dependencies.
Thanks
QuestionNot working in RubyMotionmemberMember 896498111-May-12 23:57 
Hi I am attempting to use the eSpeak engine as a 3rd party library in RubyMotion. (www.rubymotion.com)
 
when I run the simulator I get the following error:
 
Unknown tune 'c1'
Unknown tune 'q1'
Unknown tune 'e1'
2012-05-12 10:54:44.306 FuzzyClock[41504:10703] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:   dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
   Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
   Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security
 
do you have any idea what I did wrong ?
AnswerRe: Not working in RubyMotionmemberJozef Bozek14-May-12 21:24 
Hi, in error stack i see you are using ios sdk 5.1, i did not test my eSpeak library with this version (unfortunately i can not update my XCode to a new version).
Did you try to buikld and run your app on ios sdk 5.0 ?
QuestionAre there North American voice available? Female voice is better.memberMember 887001823-Apr-12 2:39 
Thanks for providing this nice tool. I installed it and ran it, it pretty good. How can I choice different voice like using North American voice ? can I pick male or female voice ?
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:22am.

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
Web02 | 2.6.130617.1 | Last Updated 24 Jan 2012
Article Copyright 2012 by Jozef Bozek
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid