ComDX doesn't exist anymore: how can I manage ?

Just starting out? Need help? Post your questions and find answers here.
Fiwip
User
User
Posts: 27
Joined: Tue Feb 24, 2004 2:42 pm

ComDX doesn't exist anymore: how can I manage ?

Post by Fiwip »

Hello,

The ComDx library from Danilo included in the full PB package in april 2002 has gone as I can read in a few posts on the forum. And it is not included anymore in his PureTools1021.

I am working on a tut for chess with "text to speech" and found 2 posts from Danilo helpful on the subject (thanks for that).

Code: Select all

; English forum: 
; Author: DANILO 
; Date: 21. January 2003 

;----------------------------------------- 
;----------------------------------------- 
#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 < 0 Or 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 
  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$ = "<voice required="+Chr(34)+"Gender=Male"+Chr(34)+">"+String 
  Else 
    Text$ = "<voice required="+Chr(34)+"Gender=Female"+Chr(34)+">"+String 
  EndIf 
  ; Set Volume 
  Text$ = "<volume level="+Chr(34)+Str(CurrentVolume)+Chr(34)+"/>"+Text$ 
  ; Set Speed 
  Text$ = "<rate absspeed="+Chr(34)+Str(CurrentSpeed)+Chr(34)+">"+Text$ 
  ; Set Pitch 
  Text$ = "<pitch absmiddle="+Chr(34)+Str(CurrentPitch)+Chr(34)+"/>"+Text$ 
  
  length = Len(Text$)*2+10 
  *mem = AllocateMemory(length) 
  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 
;----------------------------------------- 
;----------------------------------------- 
; ExecutableFormat=Windows 
; FirstLine=1 
; EOF
So the question is: how I can manage this "CallCOM(80,VoiceObject,*mem,0,0)" ?

Btw why this has been stopped ? (As far as I can read on the forum, it has been erased from PB package bc it was already included in the PureTools package, but now it is nowhere ?)

Thanks for your help,

Fiwip
FloHimself
Enthusiast
Enthusiast
Posts: 229
Joined: Wed May 14, 2003 3:38 pm
Location: Lüneburg - Germany

Post by FloHimself »

hi,

you don't need to use ComDX anymore. Just use the PureBasic Interface feature. Here is a very quick hack, based on Danilos code:

Code: Select all

Interface ISpNotifySource Extends IUnknown
  SetNotifySink(a)
  SetNotifyWindowMessage(a,b,c,d)
  SetNotifyCallbackFunction(a,b,c)
  SetNotifyCallbackInterface(a,b,c)
  SetNotifyWin32Event()
  WaitForNotifyEvent(a)
  GetNotifyEventHandle()
EndInterface

Interface ISpEventSource Extends ISpNotifySource
  SetInterest(a,b)
  GetEvents(a,b,c)
  GetInfo(a)
EndInterface

Interface ISpVoice Extends ISpEventSource
  SetOutput(a,b)
  GetOutputObjectToken(a)
  GetOutputStream(a)
  Pause()
  Resume()
  SetVoice(a)
  GetVoice(a)
  Speak(a,b,c)
  SpeakStream(a,b,c)
  GetStatus(a,b)
  Skip(a,b,c)
  SetPriority(a)
  GetPriority(a)
  SetAlertBoundary(a)
  GetAlertBoundary(a)
  SetRate(a)
  GetRate(a)
  SetVolume(a)
  GetVolume(a)
  WaitUntilDone(a)
  SetSyncSpeakTimeout(a)
  GetSyncSpeakTimeout(a)
  SpeakCompleteEvent()
  IsUISupported(a,b,c,d)
  DisplayUI(a,b,c,d,e)
EndInterface

#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) 

Global VoiceObject.ISpVoice

Procedure Speak(Text$)
  length = Len(Text$)*2+10 
  *mem = AllocateMemory(length) 
  MultiByteToWideChar_(#CP_ACP ,0,Text$,-1,*mem, length) 
  VoiceObject\Speak(*mem,0,0)
EndProcedure

CoInitialize_(0) 
If CoCreateInstance_(?CLSID_SpVoice, 0, #CLSCTX_ALL, ?IID_ISpVoice, @VoiceObject.ISpVoice) = 0 
  VoiceObject\SetVolume(100)
  VoiceObject\SetRate(-5)
  Speak("You don't need to use ComDX anymore. Just use the PureBasic Interface feature.")
Else 
  MessageRequester("ERROR","MS SPEECH API not installed",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 
Fiwip
User
User
Posts: 27
Joined: Tue Feb 24, 2004 2:42 pm

Post by Fiwip »

Many thanks for your explanations. PB is running fast -very good- but sometimes not so easy to follow all the changes for the kind of user I am: using it for a while then stop then again.

So thanks to you and to this helpful forum.

Now I have to make it speech for any file *.txt loaded from the currentdirectory !

Fiwip
Post Reply