Speech library for the DEVICE!

agraham

Expert
Licensed User
Longtime User
After the deafening silence that accompanied my ControlsExDesktop library lets see if this one gets more interest. :)

I already did a speech library for the desktop http://www.b4x.com/forum/showthread.php?t=1056 but that was not portable to the device as it used Microsoft's Speech API that is not available on most devices. So I have (almost literally!) sweated blood for a few days to try to get a sound library on the device. After several false starts I have finally managed to port the flite http://fife.speech.cs.cmu.edu/flite/ open source speech engine to the device. It was was a bit of a messy port but it seems to work fine on my device and has the simplest possible interface to B4PPC.

As it was too large to upload directly Erel kindly accepted it by email and has made it available here :-
http://www.b4x.com/files/fliteDevice.zip
 

derez

Expert
Licensed User
Longtime User
voice

Amazing, Agraham !

I tried it and it works !:sign0060:

Do you have any means of control like pitch or volume ?

I may find use for it in my off-road navigation program, as instructions to follow a route.
 

agraham

Expert
Licensed User
Longtime User
Do you have any means of control like pitch or volume ?
No unfortunately. The original writers of the software didn't expose any means of controlling the speech engine. I presume such things are characteristic of each "voice", of which there is just one for this library.
 

alfcen

Well-Known Member
Licensed User
Longtime User
Hello agraham,

Thanks so much for this awesome wrapper!
Fortunately, the engine works for me in the application directory - what a relief :)

The voice sounds a bit scary, but can be adjusted within limits by playing with the text spelling.
Longer texts, say, in the order of 160 characters, cause a native exception error, though.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Longer texts, say, in the order of 160 characters, cause a native exception error, though.
The limit seems to be 127 characters, a value probably not without significance as it is the maximum value of an unsigned byte. I just missed picking this up as my largest test string was 123 characters long.

I didn't mention it but Say actually returns the number of characters spoken - a hangover from debugging the interface - so you can confirm this limit yourself if you wished.

Because of limitations in the Compact Framework I had trouble marshalling .NET wide strings into C type narrow strings across the DLL call and it is a bit ugly on the native side so I guess that it is related to this. I don't think there is any deeper problem, just an interface problem between the two different sorts of DLL.

I'll look at it to see if it is an easy fix - otherwise you will just have to keep the text shorter than this limit.
 

alfcen

Well-Known Member
Licensed User
Longtime User
No major problem, agraham, the text could be chunked for longer text conversions while the return value is of great help. Perhaps a 'shut up' (stop)command would be nice to have :)
 

agraham

Expert
Licensed User
Longtime User
Thanks so much for this awesome wrapper!
This was a huge amount of work - not just a wrapper. I had to port the original speech engine C code that was a Unix command line app. to the Visual Studio ARM native C++ compiler and then pack it into a native device DLL and then write the .NET wrapper! The wrapper was the easy bit - it took about 10 minutes - the big native DLL took more than a week of 8+ hour days including false starts!
 

agraham

Expert
Licensed User
Longtime User
I'll look at it to see if it is an easy fix
I have fixed it. My classic "C" is a bit rusty - the native ARM C++ compiler thinks that "chars" map to signed bytes - I was assuming unsigned :( Look out for a link to appear to "fliteDeviceUpdate1". Only the big native fliteDLL.dll is changed.

Perhaps a 'shut up' (stop)command would be nice to have :)
Sorry, it's not possible because it is running on the B4PPC thread so you don't get control back to stop it until it has stopped anyway!
 

alfcen

Well-Known Member
Licensed User
Longtime User
Please accept my sincere apologies, agraham. I did not mean to diminish your hard work. I am just not as deep into the matter as you are, thus ignorant about the kind and amount of work involved with DLLs and C programming. I hope you are in the mood for an apology.

I have fixed it.

Sounds great! (I almost completed a chunk routine) :)

Thanks so much, I will look out for the update link.

I understand about the stop command and will work around it.

Cheers
Robert
 

agraham

Expert
Licensed User
Longtime User
I hope you are in the mood for an apology.
No need, I wan't upset at all. I just wanted you to know that behind the scenes some of this stuff can take a lot of time and effort (and background knowledge and sometimes luck) even if it is not obvious from the end result - a single call to a speech engine in this case :)
 

agraham

Expert
Licensed User
Longtime User
Look out for a link to appear to "fliteDeviceUpdate1"
The update is available but Erel has posted it under the original name on the original download link so if you have downloaded before this message appears then download again. The ReadMe is slightly updated as well. The fliteDLL.dll should be dated 1st Dec 2007 and be 3,111,936 bytes long. I am afraid my version control sucks a bit.
 

alfcen

Well-Known Member
Licensed User
Longtime User
I am speechless, while my device is talking like a waterfall. Works like a charm. agraham you did great! The engine is based on English, yet with some intentional false spelling it is possible to have Japanese, Spanish and German words pretty well pronounced. dzt will probably try it with Greek and derez with Hebrew :)

What is the appropriate credit note for all those who will use this engine?
For example:

Text-to-Speech engine by Carnegie Mellon University,
ported to the Pocket PC by Andrew Graham, UK

Please be so kind as to advise.
 

agraham

Expert
Licensed User
Longtime User
What is the appropriate credit note for all those who will use this engine?
As with a lot of open source it is a little unclear as there are lot of separate source files in the project, writen by different people at different times with sometimes different "free to use" licenses. All appear to permit virtually any use whatever, including commercial, as long as no liability reflects back upon the original writers.

This site is explicitly mentioned in the official flite documentation but distributes a pre-compiled version of the same engine with only a passing mention of its source and no explicit license conditions.

http://www.viksoe.dk/code/flite.htm

Therefore I guess that your proposal is fine but I would include a bit more description and the link http://fife.speech.cs.cmu.edu/flite/

The fliteDLL.dll is based upon the FLITE 1.3 speech synthesis engine.
FLITE originated from and is maintained by the CMU (Carnegie Mellon University) .
http://fife.speech.cs.cmu.edu/flite/

This FLITE dll was ported to the Pocket PC by Andrew Graham
Erel is closer to the commercial scene than I. No doubt he will comment if he thinks it necessary.
 

colin9876

Active Member
Licensed User
example prog please?

How do I create the voice object?
I looked at the readme and did

voice.new1
voice.say("hello world")

in App_Start but it doesnt work? what have i done wrong
 

colin9876

Active Member
Licensed User
Thanks, how did u add the object?
I did add components but it still didnt have any object listed?

Update - problem solved- worked out that u only add Flitedevice.dll, not flite.dll
 
Last edited:

agraham

Expert
Licensed User
Longtime User
what have i done wrong
Firstly it only works on the device - I have a different solution for the desktop - see the first post of this thread.

Ensure both dlls are in the same folder as your B4PPC app.

Add the fliteDevice.dll to your project by Tools->Components -> Add DLL

Add a fliteDevice object by Tools-> AddObject "SomeName"

Save the app to the folder where both dlls are located.

This should then work

SomeName.New1
SomeName.Say("Hello world")


If you get a complaint about P/Invoke then move the fliteDLL.dll to your Windows folder .

BTW just saying "it doesn't work" is not conducive to finding problems. A description of the way in which it does not work (especially with any error message) will usually get you a solution much quicker.
 

colin9876

Active Member
Licensed User
Thanks

Yes I was using the device, its a clever library. The problem was I had added both dlls as components and then it wouldnt allow me to add the object

When I only added the FliteDevice.dll component it allowed me - Just out of interest why is this?

Also in theory would it be possible to write a basic4ppc prog to run in the background, check every second or so if there is a new SMS message, and if there is read it out. So can Basic4ppc progs? a)Run in background and b)Access text messages???
 
Last edited:

agraham

Expert
Licensed User
Longtime User
When I only added the FliteDevice.dll component it allowed me - Just out of interest why is this?
I don't understand how you managed to add fliteDLL.dll as a component. As it is not a .NET assenbly you should have got an error when you tried to add it. I do.

On the other questions I suggest you start a new thread in the "Questions & Help Needed" forum.
 
Top