Text To Speech library (desktop only)

Louis

Active Member
Licensed User
Longtime User
Hi. I am trying to wrap the Microsoft SAPI so it will work with Basic4ppc. The DLL builds fine and I see all methods, but when I run it on the desktop I get an error saying that the speech.dll wrapper is trying to read from protected memory, but if I use native C++ the Speech.dll lib works fine. Please help! All source code is attached below for the desktop only. Thanks.
 

Cableguy

Expert
Licensed User
Longtime User
Sorry...
I cannot help, but is this dll device compatible?

I was looking for something like this for a while...
 

agraham

Expert
Licensed User
Longtime User
Louis - I am afraid that your source is a bit screwed up and I don't know that dll does so I can't help with that.

However try the following. As with all my stuff it needs .NET 2.0 and I can't be sure that it will work on your machines but it works on my laptop under XP and my desktop under Vista.

Technical note : The source code needs an interop library to access the COM object "Microsoft Speech Object Library". The Interop library included is automatically generated by VS2005 when you add the COM reference to the project. I have included the source in case anyone wants to make a stab at a .NET 1.1 version but I don't know if this is possible.

EDIT: - I've just found out that the voice selection is broken - I only have one voice installed on my main machine so I could't test it there. I have fixed it but I'll wait for some feedback to see if this library is of any use to people before posting it.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Final (?) version 1.1 of SpeechLibDesktop compiled under .NET 2.0

Source code and help file included. Sync and Async speaking with voice selection and some useful events. Sample app included.

@Erel & dzt et al. I guess this source won't compile directly under .NET 1.1 as I use the later C# 2 syntax to add events - I guess you can figure out how to fix that yourselves!


Edited by Erel: The attached file is compiled with .Net 1.1. Thank you agraham for this great library :sign0188:
 

Attachments

  • SpeechLibDesktop.zip
    60.4 KB · Views: 198

colin9876

Active Member
Licensed User
Hey, this is great but can it not run on the PocketPC? Is there a hardware barrier to speach on a PDA?

Im new to this forum but it seems a shame to be developing things 'for desktop only' because the whole beauty of this Basic4ppc product is that one can develop and run on the PocketPC without going near a desktop?
 

agraham

Expert
Licensed User
Longtime User
Hey, this is great but can it not run on the PocketPC? Is there a hardware barrier to speach on a PDA?
It's not hardware but software limitations. Microsoft didn't put the speech API into Windows Mobile because of memory and processor power limitations. As far as I know there is only one speech library for Pocket PC. It is called FLite and I haven't made it work properly. Even when it does the speech quality apparently is c**p because of said limitations.
 

bparent

Member
Licensed User
Longtime User
Speech Desktop error

Whenever I try to run this I get the following error using the included example:

"Cannot load file or assembly Interop.SpeechLib or one of its dependencies. Cannot locate file"

I have the Interop.SpeechLib.dll in the Windows directory, Basic4ppc/librarires directory, with the speechtext.sbp file.

What am I doing wrong?
 

Louis

Active Member
Licensed User
Longtime User
Hi. The Interop.Speech.dll that you moved to your Windows folder should be in the same folder as the rest of the Basic4ppc Libraries. When you decide you want to distribute your applications, all dlls should be distributed in the same folder as your source code or compiled application. This includes the Interop.Speech.dll. HTH.
 

bparent

Member
Licensed User
Longtime User
Speech Desktop error - fixed

That did it. Thanks. Thought the dll needed to be in the windows directory per earlier comment in thread. Actually, also thought I had put all the dll's with the source code in trying different things, but had not included the Interop.Speech.dll.

Hi. The Interop.Speech.dll that you moved to your Windows folder should be in the same folder as the rest of the Basic4ppc Libraries. When you decide you want to distribute your applications, all dlls should be distributed in the same folder as your source code or compiled application. This includes the Interop.Speech.dll. HTH.
 

Zenerdiode

Active Member
Licensed User
The supplied SpeechLib.cs is not allowing merging with the .exe. Was it provided for a different reason? I apologise I don't know much about the inner workings of the dll's yet.
 

agraham

Expert
Licensed User
Longtime User
It is actually the dll that is compiled with an incorrect assembly name. This didn't matter in the days before merging but it does now. I'm afraid I haven't time to revisit this at the moment, and as you need a separate interop library you can't have a single exe solution anyway.

EDIT :- This reason, hurriedly concocted before I rushed off for a dentist appontment is wrong! There are two reasons it won't compile. One is that the scource filename should be SpeechLibDesktop.cs. The other (I think) is that a reference at compile time is needed to Interop.SpeechLib.dll and Basic4ppc doesn't know this.
 
Last edited:

rgately

Member
Licensed User
Longtime User
Hi,
I have added the SpeechLibDesktop object to my test app. It works fine on my Windows XP notebook except that SayAsync behaves the same as SaySync.

What is the possibility of someone adding a few more features to the library, such as:

- get the name of the voice
- stop speaking and/or pause speaking
- resume speaking

Bob
 

agraham

Expert
Licensed User
Longtime User
except that SayAsync behaves the same as SaySync.
Are you sure? Look at the word counter. For a SaySync voice it only updates when speech ends, for an SayAsync voice it updates in real time during speech.

- get the name of the voice
- stop speaking and/or pause speaking
- resume speaking
I've added these to a new version of the library except for Stop which doesn't seem possible. However I have put in a Skip sentence method which skips forwards or backwards. I guess you could do a forwards skip of a large number to end speech. I have noticed that skip backwards while the last sentence is being spoken seems to end speech rather than skipping back, it works OK on earlier sentences so this may be a "feature" of the speech engine.

The new version is http://www.b4x.com/forum/additional-libraries/3809-desktop-text-speech-library.html

@Everyone please regard this thread closed and post any queries in the new thread.
 
Top