Hello World

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
stegemma
Posts: 859
Joined: Mon Aug 10, 2009 10:05 pm
Location: Italy
Full name: Stefano Gemma

Re: Hello World

Post by stegemma »

hgm wrote:Does anyone happen to know an example of a "Hello World" program in plain C that speaks the sentence using the Windows SAPI?
The simplest way (maybe it works, never tryed):

call ShellExecute API using as parameter an MP3 file.

Ok, ok... is not SAPI but it's simpler ;)
jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Re: Hello World

Post by jhaglund »

I would make an optional Blind database of sound files to download with a lot of different words and phrases...

Then... have a verbose option for say... the ICS chat window.

Code: Select all

 PlaySound(TEXT("C:\\Windows\\Media\\Windows Balloon.wav"), NULL, SND_FILENAME);


Use something like this with the directory full of .wav files of what was to be spoken, then use a bool array[speak] using flags 0 or 1, turning the wave files on||off ... after parsing the chat line to what is in the database of files... the words or phrases would be spoken as/after they were parsed...

[ics chat]
Hello from Crafty

[database] scan... parse chat.

[turn files on||off]
0,0,1,0,0,0,0,1,1,0,0,0,0....
(array [2 , 7, 8] = speak)

[verbose out]

Code: Select all

PlaySound(TEXT("C:\\Windows\\Media\\hello.wav"), NULL, SND_FILENAME);

sleep(500);

PlaySound(TEXT("C:\\Windows\\Media\\from.wav"), NULL, SND_FILENAME);

sleep(500);

PlaySound(TEXT("C:\\Windows\\Media\\crafty.wav"), NULL, SND_FILENAME);
or .... Research Windows SAPI :)
User avatar
hgm
Posts: 27809
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Hello World

Post by hgm »

Sven Schüle wrote:Try the bottom of this article. I have not installed the SAPI SDK so I could not compile it. But it looks plausible. You need to remove the "::" qualifiers, define COBJMACROS, change the calls "pVoice->..." into "ISpVoice_...", and hope for the best :-)

Be sure to fix the syntax error near the end of the line containing "CoCreateInstance". Also watch out for necessary #include-s.
Thanks (and also to Ricardo), this is exactly the kind of stuff I was looking for.

Unfortunately I didnot manage to pull it off. At least not with SAPI 5.1 which I downloaded and installed. When I incorporate the exampleinWinBoard, and try to compile it (after putting the sapi.h and sapi51.h in the directory so they can be included) I get an error in sapi51.h! :shock:

Code: Select all

./sapi51.h:1101: error: parse error before "__RPC__in"

    {
        BEGIN_INTERFACE

        HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
            ISpNotifySource * This,
            /* [in] */ __RPC__in REFIID riid,
            /* [iid_is][out] */
            __RPC__deref_out  void **ppvObject);

        ULONG ( STDMETHODCALLTYPE *AddRef )(
            ISpNotifySource * This);

I have not tried the alternative yet, taking a C++ example, compiling it with g++, and then linking it to the gcc-compiled WinBoard files. If possible at all, I would like to avoid the need of a C++ compiler for building WinBoard. But I have no clue as to how the error could be solved (or actually what causes it; I see no error there, unless ISpNotifySource would somehow be undefined.)

To the others:

Thanks for the suggestion, but WinBoard for JAWS is based on text-to-speech for all its spoken messages. Originally it used the TTS system that comes with the JAWS screen reader, but I am now trying to make it independent from this commercial screen reader, as nowadays many alternatives exist, so many people do not have it. I already succeeded to make it work for the NVDA open-source screen reader, but I would also like to support the native Windows SAPI, for the benefit of people that do not need to use a screen reader, but would like to have sound output for other reasons.

But I have no intension to completely redesign the interface, basing it on WAV or MP3 files. I am only looking for alternative low-level interfaces that can make the existing text-to-speech system work.
User avatar
jshriver
Posts: 1342
Joined: Wed Mar 08, 2006 9:41 pm
Location: Morgantown, WV, USA

Re: Hello World

Post by jshriver »

Do you have to use the Windows interface?

Why not festival then it would be cross platform compatible.
User avatar
hgm
Posts: 27809
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Hello World

Post by hgm »

I don't know anything about festival. Is that an front-end for the Windows speech API? It is going into a version of WinBoard, which would not be cross-platform for a zillion of other reasons.
Last edited by hgm on Wed Sep 28, 2011 9:48 pm, edited 2 times in total.
JVMerlino
Posts: 1357
Joined: Wed Mar 08, 2006 10:15 pm
Location: San Francisco, California

Re: Hello World

Post by JVMerlino »

stegemma wrote:
hgm wrote:Does anyone happen to know an example of a "Hello World" program in plain C that speaks the sentence using the Windows SAPI?
The simplest way (maybe it works, never tryed):

call ShellExecute API using as parameter an MP3 file.

Ok, ok... is not SAPI but it's simpler ;)
Indeed, this is the simplest way, but it depends on how large your spoken vocabulary is going to be.

In case anybody cares, in Chessmaster, the total MP3 audio files for all "spoken moves" is a little over 7MB. But it contains a great deal of other stuff that HG probably doesn't need:

-- different versions of "takes" and "captures", so it doesn't get boring
-- messages that tell you you have made in illegal move, plus why it was illegal (this was the most costly)
-- each square had its own audio file (rather than one for each row and each column), so it sounds less "mechanical"

And it was also recorded in a studio with high quality audio, resulting in larger files than necessary. We had a total of 465 different audio pieces just for this.

jm
User avatar
JuLieN
Posts: 2949
Joined: Mon May 05, 2008 12:16 pm
Location: Bordeaux (France)
Full name: Julien Marcel

Re: Hello World

Post by JuLieN »

That's impressive, John, and ChessMaster is of course a top quality product! :) But I believe like H.G. that vocal synthesis are the future.

I now have Lion on my Mac, and the speech synthesis made incredible progress! I tried various language I am familiar with (french, english, swedish, spanish...), all with various characters (male, female...), and each time the result was very realistic. Each character weights a lot (I remember that an average size for a french character was around 400 MB), which is the prize to pay for quality, too. You should ask a Mac owner to show it to you, you'll certainly get impressed too like I've been. :)

Here's an example video (among many) on youTube:
http://www.youtube.com/watch?v=KHE__cF_Ljk

It's not 100% perfect in english,a though it's still very good.
"The only good bug is a dead bug." (Don Dailey)
[Blog: http://tinyurl.com/predateur ] [Facebook: http://tinyurl.com/fbpredateur ] [MacEngines: http://tinyurl.com/macengines ]
User avatar
jshriver
Posts: 1342
Joined: Wed Mar 08, 2006 9:41 pm
Location: Morgantown, WV, USA

Re: Hello World

Post by jshriver »

JuLieN wrote: speech synthesis made incredible progress!
OT but I agree. A friend often sends me email/sms messages from his droid and composes it via transcription. That is on an embedded system. Speech synthesis is even better, absolutely amazing technology.