Speech library for the DEVICE!

Discussion in 'Additional Libraries' started by agraham, Nov 30, 2007.

  1. agraham

    agraham Expert Licensed 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.basic4ppc.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.basic4ppc.com/files/fliteDevice.zip
     
  2. derez

    derez Expert Licensed 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.
     
  3. agraham

    agraham Expert Licensed User

    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.
     
  4. alfcen

    alfcen Well-Known Member Licensed 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: Dec 1, 2007
  5. agraham

    agraham Expert Licensed User

    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.
     
  6. alfcen

    alfcen Well-Known Member Licensed 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 :)
     
  7. agraham

    agraham Expert Licensed User

    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!
     
  8. agraham

    agraham Expert Licensed User

    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.

    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!
     
  9. alfcen

    alfcen Well-Known Member Licensed 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.

    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
     
  10. agraham

    agraham Expert Licensed User

    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 :)
     
  11. agraham

    agraham Expert Licensed User

    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.
     
  12. alfcen

    alfcen Well-Known Member Licensed 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:

    Please be so kind as to advise.
     
  13. agraham

    agraham Expert Licensed User

    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/

    Erel is closer to the commercial scene than I. No doubt he will comment if he thinks it necessary.
     
  14. Erel

    Erel Administrator Staff Member Licensed User

    I will just comment that I'm amazed to see your projects, and I'm sure that this library will be useful for many of us :sign0098:.
    I want to thank you on the behalf of all our community for these great contributions.
     
  15. colin9876

    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
     
  16. CANCUNATNIGHT

    CANCUNATNIGHT Member

    Check this.

    Have you tested something about this...?
     

    Attached Files:

  17. colin9876

    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: Dec 1, 2007
  18. agraham

    agraham Expert Licensed User

    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.
     
  19. colin9876

    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: Dec 2, 2007
  20. agraham

    agraham Expert Licensed User

    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.
     
Loading...