IonicWind Software

IWBasic => The Roundtable => Topic started by: Ionic Wind Support Team on April 04, 2008, 02:41:23 PM

Title: Simple speech
Post by: Ionic Wind Support Team on April 04, 2008, 02:41:23 PM
Playing with the new dispatch helper commands:


IDispatch speech
string text
speech = CreateComObject("Sapi.SpVoice","")
if speech <> NULL
while ucase$(text) <> "END"
PRINT "Enter something to say, \"END\" to exit"
INPUT ">",text
CallObjectMethod(speech,".Speak(%s)",text)
endwhile
speech->release()
else
PRINT "Sapi object not available"
do:until inkey$ <> ""
endif

END


Works if you have the speech API installed, or one of the Microsoft products that install it, such as Office.  On Vista I beleive it is included with the os.

Paul.
Title: Re: Simple speech
Post by: Ionic Wind Support Team on April 04, 2008, 05:08:16 PM
Part 2.   Selecting which voice to use.  Works if you have the Speech SDK (Sapi 5.1) installed.


DECLARE CDECL EXTERN _dhPutRef(pointer pDisp, WSTRING szMember, ...),int

IDispatch speech
IDispatch voice
string text
pointer pText
int count,x
speech = CreateComObject("Sapi.SpVoice","")
if speech+0 <> NULL
SetComProperty(speech,".Rate = %d",0)
GetComProperty(speech,"%d",&count,".GetVoices.Count")
PRINT "Select which voice to use"
for x = 1 to count
GetComProperty(speech,"%o",&voice,".GetVoices.Item(%d)",x-1)
GetComProperty(voice,"%s",&pText,".GetDescription")
PRINT x,#<STRING>pText
FreeCOMString(pText)
next x
input ">",x
GetComProperty(speech,"%o",&voice,".GetVoices.Item(%d)",x-1)
if(voice <> NULL)
print "Voice found!"
_dhPutRef(speech,L".Voice = %o",voice)
endif

while ucase$(text) <> "END"
PRINT "Enter something to say, \"END\" to exit"
INPUT ">",text
CallObjectMethod(speech,".Speak(%s)",text)
endwhile
speech->release()
else
PRINT "Sapi object not available"
do:until inkey$ <> ""
endif

END


I havent converted _dhPutRef to a built in command yet, hence the need for the declare.

Paul.
Title: Re: Simple speech
Post by: Brian on April 05, 2008, 01:21:08 PM
Paul,

Works for me (XP SP2)! Can you alter the speed and intonation somehow?

Brian
Title: Re: Simple speech
Post by: Ionic Wind Support Team on April 05, 2008, 02:57:36 PM
The first line

SetComProperty(speech,".Rate = %d",0)

Change the '0' to any value from -10 to 10 and the rate will change.

Have to look up the pitch property.


SetComProperty(speech,".Volume = %d",50)

Works too.
Title: Re: Simple speech
Post by: Bruce Peaslee on April 06, 2008, 09:16:57 AM
What fun! I can see myself getting into all sorts of trouble  :D
Title: Re: Simple speech
Post by: Jerry Muelver on April 06, 2008, 09:55:01 AM
I haven't gone into this yet.... Can I make the speech anything I want, like phonetic transcription or foreign language?
Title: Re: Simple speech
Post by: LarryMc on April 06, 2008, 10:20:26 AM
Looking briefly at the API you can pronounce anything you want with phonemes.

Larry
Title: Re: Simple speech
Post by: REDEBOLT on April 06, 2008, 12:34:27 PM
When I try to compile, I get the following messages:

QuoteCompiling...
speech.eba
File: F:\EBDev\projects\BOB\speech.eba (1) unknown type
File: F:\EBDev\projects\BOB\speech.eba (3) Warning: undeclared function 'CreateComObject'
File: F:\EBDev\projects\BOB\speech.eba (8) Warning: undeclared function 'CallObjectMethod' - )
File: F:\EBDev\projects\BOB\speech.eba (10) invalid argument - )
File: F:\EBDev\projects\BOB\speech.eba (10) undeclared method - )
Error(s) in compiling F:\EBDev\projects\BOB\speech.eba

I downloaded in 2005 and installed it on my winxp/sp 2.
The download said it was the 5.1 version.

I searched my WINDOWS for a dll named speech but found none. What I did find was SPEECHSDK51.EXE-0047143A.pf.
Title: Re: Simple speech
Post by: pistol350 on April 06, 2008, 12:41:48 PM
Hi BOB!
I assume you installed the latest version of Ebasic.
Title: Re: Simple speech
Post by: Ionic Wind Support Team on April 06, 2008, 02:02:16 PM
Bob,
you need 1.6 or 1.61

Paul
Title: Re: Simple speech
Post by: REDEBOLT on April 06, 2008, 07:08:57 PM
Thanks all.

I will install that right away.
Title: Re: Simple speech
Post by: pistol350 on April 27, 2008, 12:08:18 PM

if speech+0 <> NULL
...


There is something i don't understand.
Assuming "speech+0" = speech, why adding "0" to "speech" then ?

Maybe my assumption is false.
Any explanations please ?