May 16, 2024, 10:02:28 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Simple speech

Started by Ionic Wind Support Team, April 04, 2008, 02:41:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ionic Wind Support Team

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.
Ionic Wind Support Team

Ionic Wind Support Team

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.
Ionic Wind Support Team

Brian

Paul,

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

Brian

Ionic Wind Support Team

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.
Ionic Wind Support Team

Bruce Peaslee

What fun! I can see myself getting into all sorts of trouble  :D
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Jerry Muelver

I haven't gone into this yet.... Can I make the speech anything I want, like phonetic transcription or foreign language?

LarryMc

Looking briefly at the API you can pronounce anything you want with phonemes.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

REDEBOLT

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.
Regards,
Bob

pistol350

Hi BOB!
I assume you installed the latest version of Ebasic.
Regards,

Peter B.

Ionic Wind Support Team

Bob,
you need 1.6 or 1.61

Paul
Ionic Wind Support Team

REDEBOLT

Thanks all.

I will install that right away.
Regards,
Bob

pistol350


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 ?
Regards,

Peter B.