ComDX Library
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
There are some examples in this Forum - self explaining.
You have to build your own constants for the #Method argument.
Every interface begins with QueryInterface, AddRef and Release
and the Offsets are always 4 Bytes (a Pointer) for each Member.
You see ?? Its always the same...
How you can get the object is different and
depends on the stuff you need it for.
For DX7 you get the DirectDraw-Object with
DirectDrawCreateEx_().
For other stuff you can get it with CoCreateInstance_() mostly.
Search the forum (Tips&Tricks, maybe other forums) and
you should find examples.
I remember posting at least 2 examples here,
1 was for Shell-Links (shortcuts) and other
was for hiding the app from Taskbar.
If you need help for a special interface,
you should ask more precisely and tell me
what you want to do - maybe i can take a look at it.
cya,
...Danilo
(registered PureBasic user)
There are some examples in this Forum - self explaining.
Code: Select all
CallCOM( #Method, object [, Arguments ...] ) #Method is a number (constant) and specifies the
offset of the method in the interface.
object is the object you initialized before.Every interface begins with QueryInterface, AddRef and Release
and the Offsets are always 4 Bytes (a Pointer) for each Member.
Code: Select all
Example for IDirectDraw7 interface:
; standard Methods
#DD_QueryInterface = 0
#DD_AddRef = 4
#DD_Release = 8
; now the real Methods
#DD_Compact = 12
#DD_CreateClipper = 16
[...]
#DD_EvaluateMode = 116
Example for IDirectDrawGammaControl interface:
; standard Methods
#DDGammaControl_QueryInterface = 0
#DDGammaControl_AddRef = 4
#DDGammaControl_Release = 8
; now the real Methods
#DDGammaControl_GetGammaRamp = 12
#DDGammaControl_SetGammaRamp = 16
Example for IShellLink interface:
#ShellLink_QueryInterface = 0
#ShellLink_AddRef = 4
#ShellLink_Release = 8
#ShellLink_GetPath = 12
#ShellLink_GetIDList = 16
#ShellLink_SetIDList = 20
[...]How you can get the object is different and
depends on the stuff you need it for.
For DX7 you get the DirectDraw-Object with
DirectDrawCreateEx_().
For other stuff you can get it with CoCreateInstance_() mostly.
Search the forum (Tips&Tricks, maybe other forums) and
you should find examples.
I remember posting at least 2 examples here,
1 was for Shell-Links (shortcuts) and other
was for hiding the app from Taskbar.
If you need help for a special interface,
you should ask more precisely and tell me
what you want to do - maybe i can take a look at it.
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ebs.
Danilo,
Thanks for the explanation. I'm trying to use Microsoft's Speech API DLL (sapi.dll) so I can control a text-to-speech synthesizer. I believe that I only need to use the SpVoice object, and maybe the SpFileStream object if I want to speak the contents of a file. I have a Visual Basic program and those are the only two objects used.
Thanks again for yor help,
Eric
Danilo,
Thanks for the explanation. I'm trying to use Microsoft's Speech API DLL (sapi.dll) so I can control a text-to-speech synthesizer. I believe that I only need to use the SpVoice object, and maybe the SpFileStream object if I want to speak the contents of a file. I have a Visual Basic program and those are the only two objects used.
Thanks again for yor help,
Eric
If you need help for a special interface,
you should ask more precisely and tell me
what you want to do - maybe i can take a look at it.
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ebs.
Can anyone help me to find out more about the interface and methods in SAPI.DLL?
Eric
Can anyone help me to find out more about the interface and methods in SAPI.DLL?
Eric
Originally posted by ebs
Danilo,
Thanks for the explanation. I'm trying to use Microsoft's Speech API DLL (sapi.dll) so I can control a text-to-speech synthesizer. I believe that I only need to use the SpVoice object, and maybe the SpFileStream object if I want to speak the contents of a file. I have a Visual Basic program and those are the only two objects used.
Thanks again for yor help,
Eric
If you need help for a special interface,
you should ask more precisely and tell me
what you want to do - maybe i can take a look at it.
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
This code lets your computer speak:
If it tells you "MS Speech API not installed", get
the http://download.microsoft.com/download/ ... hsdk51.exe (68MB).
All documentation is in the SDK and i wrote
this example in a few minutes with this infos.
cya,
...Danilo
(registered PureBasic user)
This code lets your computer speak:
Code: Select all
#CLSCTX_INPROC_SERVER = $1
#CLSCTX_INPROC_HANDLER = $2
#CLSCTX_LOCAL_SERVER = $4
#CLSCTX_REMOTE_SERVER = $10
#CLSCTX_ALL = (#CLSCTX_INPROC_SERVER|#CLSCTX_INPROC_HANDLER|#CLSCTX_LOCAL_SERVER|#CLSCTX_REMOTE_SERVER)
Procedure InitSpeech()
Shared VoiceObject
CoInitialize_(0)
If CoCreateInstance_(?CLSID_SpVoice, 0, #CLSCTX_ALL, ?IID_ISpVoice, @VoiceObject) = 0
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
DataSection
CLSID_SpVoice:
;96749377-3391-11D2-9EE3-00C04F797396
Data.l $96749377
Data.w $3391,$11D2
Data.b $9E,$E3,$00,$C0,$4F,$79,$73,$96
IID_ISpVoice:
;6C44DF74-72B9-4992-A1EC-EF996E0422D4
Data.l $6C44DF74
Data.w $72B9,$4992
Data.b $A1,$EC,$EF,$99,$6E,$04,$22,$D4
EndDataSection
EndProcedure
Procedure Speak(String.s)
Shared VoiceObject
length = Len(String)*2+10
*mem = AllocateMemory(1,length,0)
MultiByteToWideChar_(#CP_ACP ,0,String,-1,*mem,length)
CallCOM(80,VoiceObject,*mem,0,0)
EndProcedure
Procedure CloseSpeech()
Shared VoiceObject
CallCOM(08,VoiceObject)
CoUninitialize_()
EndProcedure
; start code
If InitSpeech()
Speak("Hello e b s!") : Delay(300)
Speak("Iam your speaking computer") : Delay(100)
Speak("Welcome to a new world!") : Delay(100)
Speak("Lets dance") : Delay(1000)
Speak("Greetings... Danilo")
CloseSpeech()
Else
MessageRequester("ERROR","MS Speech API not installed",0)
EndIfthe http://download.microsoft.com/download/ ... hsdk51.exe (68MB).
All documentation is in the SDK and i wrote
this example in a few minutes with this infos.
cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Berikco.
Very nice Danilo
Hope my computer does not start talking as much as my wi.... ups...
Regards,
Berikco
http://www.benny.zeb.be
Very nice Danilo
Hope my computer does not start talking as much as my wi.... ups...
Regards,
Berikco
http://www.benny.zeb.be
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fweil.
Great Danilo ... I am going about to start playing with and see what is customizable ...
I now have some needs to localize speech in french for example.
But your sample shows well how to start and it makes it easy.
Thank you.
Francois Weil
14, rue Douer
F64100 Bayonne
Great Danilo ... I am going about to start playing with and see what is customizable ...
I now have some needs to localize speech in french for example.
But your sample shows well how to start and it makes it easy.
Thank you.
Francois Weil
14, rue Douer
F64100 Bayonne
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by ebs.
Danilo,
I know I'm being a pain, but can I ask for a little more help? Can you give me an example of how to use the "SetVoice()" and "GetVoices()" functions? In Visual Basic, I can specify the voice I want by name, as in:
'Create a SAPI voice
Set Voice = New SpVoice
Set Voice.Voice = Voice.GetVoices("Name=mike16").Item(0)
I don't know how to deal with the SpObjectToken interface in PB.
Thanks again for all your help!
Eric
Danilo,
I know I'm being a pain, but can I ask for a little more help? Can you give me an example of how to use the "SetVoice()" and "GetVoices()" functions? In Visual Basic, I can specify the voice I want by name, as in:
'Create a SAPI voice
Set Voice = New SpVoice
Set Voice.Voice = Voice.GetVoices("Name=mike16").Item(0)
I don't know how to deal with the SpObjectToken interface in PB.
Thanks again for all your help!
Eric
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
fweil:
> I now have some needs to localize speech in french for example.
The http://www.microsoft.com/speech/techinfo/faq/ says only English is available.
With some additional packages you may have chinese and japanese too.
To support many other languages, somebody has to buy
a http://www.microsoft.com/speech/evaluat ... ngines.asp.
For example, http://www.speechworks.com/ has some more voices
for different languages available. French example .WAV (female Sandra) is http://www.speechworks.com/products/tts ... andraTessa
All the speech technologie is very complicated and not cheap,
but i think you know that already.
You have to email most of the engine makers to get price infos.
ebs:
The whole thing with voices isnt that easy. You can
request a new voice from the engine, but if its not
available, you may hear nothing.
In WinXP 1 male voice is installed by default and you
can get 2 additional voices (male+female).
After installing the Speech SDK, you have 3 voices.
I installed the SDK on Win2k and wrote a test with
3 different voices.
Me, my girlfriend and my mother:
As you can see (with installed SDK), you can change some
voice settings with XML tags inserted into the text.
It needs some more time to try all things and write many
more procedures - but i´m not really interested in this.
Its fun to play with, but thats all (for me).
Maybe the above code helps a bit..
cya,
...Daniloooowwww
(registered PureBasic user)
fweil:
> I now have some needs to localize speech in french for example.
The http://www.microsoft.com/speech/techinfo/faq/ says only English is available.
With some additional packages you may have chinese and japanese too.
To support many other languages, somebody has to buy
a http://www.microsoft.com/speech/evaluat ... ngines.asp.
For example, http://www.speechworks.com/ has some more voices
for different languages available. French example .WAV (female Sandra) is http://www.speechworks.com/products/tts ... andraTessa
All the speech technologie is very complicated and not cheap,
but i think you know that already.
You have to email most of the engine makers to get price infos.
ebs:
The whole thing with voices isnt that easy. You can
request a new voice from the engine, but if its not
available, you may hear nothing.
In WinXP 1 male voice is installed by default and you
can get 2 additional voices (male+female).
After installing the Speech SDK, you have 3 voices.
I installed the SDK on Win2k and wrote a test with
3 different voices.
Me, my girlfriend and my mother:
Code: Select all
;-----------------------------------------
;-----------------------------------------
#CLSCTX_INPROC_SERVER = $1
#CLSCTX_INPROC_HANDLER = $2
#CLSCTX_LOCAL_SERVER = $4
#CLSCTX_REMOTE_SERVER = $10
#CLSCTX_ALL = (#CLSCTX_INPROC_SERVER|#CLSCTX_INPROC_HANDLER|#CLSCTX_LOCAL_SERVER|#CLSCTX_REMOTE_SERVER)
Procedure FemaleVoice()
; Select Female Voice
Shared SelectedVoice
SelectedVoice = 0
EndProcedure
Procedure MaleVoice()
; Select Male Voice
Shared SelectedVoice
SelectedVoice = 1
EndProcedure
Procedure SetVoiceVolume(Volume)
; Set Voice Volume ( 0 - 100 )
Shared CurrentVolume
If Volume 100 : Volume = 100 : EndIf
CurrentVolume = Volume
EndProcedure
Procedure SetVoiceSpeed(Speed)
; Set Speed of Voice
; 0 = default speed
; values can be between -10 and 10
Shared CurrentSpeed
CurrentSpeed = Speed
EndProcedure
Procedure SetVoicePitch(Pitch)
; Set Voice Pitch
; values can be between -10 and 10
Shared CurrentPitch
If Pitch 10 : Pitch = 10 : EndIf
CurrentPitch = Pitch
EndProcedure
Procedure InitSpeech()
Shared VoiceObject
CoInitialize_(0)
If CoCreateInstance_(?CLSID_SpVoice, 0, #CLSCTX_ALL, ?IID_ISpVoice, @VoiceObject) = 0
SetVoiceVolume(100)
SetVoiceSpeed(0)
SetVoicePitch(0)
MaleVoice()
ProcedureReturn 1
Else
ProcedureReturn 0
EndIf
DataSection
CLSID_SpVoice:
;96749377-3391-11D2-9EE3-00C04F797396
Data.l $96749377
Data.w $3391,$11D2
Data.b $9E,$E3,$00,$C0,$4F,$79,$73,$96
IID_ISpVoice:
;6C44DF74-72B9-4992-A1EC-EF996E0422D4
Data.l $6C44DF74
Data.w $72B9,$4992
Data.b $A1,$EC,$EF,$99,$6E,$04,$22,$D4
EndDataSection
EndProcedure
Procedure Speak(String.s)
Shared VoiceObject, SelectedVoice, CurrentVolume, CurrentSpeed, CurrentPitch
; Set Voice (male or female)
If SelectedVoice = 1
Text$ = ""+String
Else
Text$ = ""+String
EndIf
; Set Volume
Text$ = ""+Text$
; Set Speed
Text$ = ""+Text$
; Set Pitch
Text$ = ""+Text$
length = Len(Text$)*2+10
*mem = AllocateMemory(1,length,0)
MultiByteToWideChar_(#CP_ACP ,0,Text$,-1,*mem,length)
CallCOM(80,VoiceObject,*mem,0,0)
EndProcedure
Procedure CloseSpeech()
Shared VoiceObject
CallCOM(08,VoiceObject)
CoUninitialize_()
EndProcedure
; Voices
Procedure Speaker_Danilo()
MaleVoice()
SetVoiceSpeed(-2)
SetVoicePitch(3)
EndProcedure
Procedure Speaker_Jennifer()
FemaleVoice()
SetVoiceSpeed(-2)
SetVoicePitch(10)
EndProcedure
Procedure Speaker_Mother()
FemaleVoice()
SetVoicePitch(-10)
SetVoiceSpeed(0)
EndProcedure
; start code
If InitSpeech()
Speaker_Danilo()
Speak("Hello everybody!") : Delay(100)
Speak("my girlfriend is here too now") : Delay(100)
Speak("Say hello - babe") : Delay(100)
Speaker_Jennifer()
Speak("Hi e b s - my name is Jennifer")
Speaker_Danilo()
Speak("Hey, my mother just returned from supermarket"): Delay(50)
Speak("Say hello mom"): Delay(50)
Speaker_Mother()
Speak("Hi, iam the big mother")
Speaker_Danilo()
Speak("Greetings...")
SetVoiceSpeed(-10)
SetVoicePitch(-10)
Speak("Danilo")
CloseSpeech()
Else
MessageRequester("ERROR","MS Speech API not installed",0)
EndIf
;-----------------------------------------
;-----------------------------------------
voice settings with XML tags inserted into the text.
It needs some more time to try all things and write many
more procedures - but i´m not really interested in this.
Its fun to play with, but thats all (for me).
Maybe the above code helps a bit..
cya,
...Daniloooowwww
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by DemonHell.
Unfortunatly, you`ll still see her lips move, but you wont hear a thing
Beriko, just right click on your wife,then drag her volume slider down to zero.Originally posted by Berikco
Very nice Danilo
Hope my computer does not start talking as much as my wi.... ups...
Unfortunatly, you`ll still see her lips move, but you wont hear a thing
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Paul.
Maybe you could try: HideWindow(#Wife,1) ??
----------
Visit the PB Resources Site at http://www.reelmediaproductions.com/pb
Originally posted by DemonHell
Unfortunatly, you`ll still see her lips move, but you wont hear a thing![]()
Maybe you could try: HideWindow(#Wife,1) ??
----------
Visit the PB Resources Site at http://www.reelmediaproductions.com/pb
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Berikco.

Good thing is he wispers, not so much noice in the house
Regards,
Berikco
http://www.benny.zeb.be
My Wispering parrot i Mean...Originally posted by Berikco
Hope my computer does not start talking as much as my wi.... ups...
Good thing is he wispers, not so much noice in the house
Regards,
Berikco
http://www.benny.zeb.be
The syntax for AllocateMemory() changed quite a while ago.sabater wrote:AllocateMemory():Incorrect number of of parameters
You found a pretty old code. Anyway, the correct syntax would be:
Code: Select all
*mem = AllocateMemory(length)
The next "problem" you'll encounter is that the code uses an external
library: CallCOM. To solve this, either use the library (*) or update the code
accordingly, as CallCOM() isn't needed anymore since PB version 3.8x
(Look for Interface/EndInterface).
* viewtopic.php?t=15831
Good programmers don't comment their code. It was hard to write, should be hard to read.
