Library Speak_lib

Share your advanced PureBasic knowledge/code with the community.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Library Speak_lib

Post by IdeasVacuum »

ah, no, it was in fact the Unicode thing - I always have Unicode as default :mrgreen:

Edit: Now it's working, there is another strange but welcome factor - the speech is superior to the Microsoft default setting.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Library Speak_lib

Post by dobro »

the speech is superior
? superior ?? :shock: in volume ?
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Library Speak_lib

Post by IdeasVacuum »

In clarity - I do not know why, must be the default MS settings.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Library Speak_lib

Post by dobro »

this code of Flype , work in Unicode Mode ;)

an use the "Token" (base64 encode)( here in French )

Code: Select all

; Ce code à été écrit par Sapero avec le language Aurora Compiler
; Traduit en Purebasic By Nico
; exemple de Flype

#CLSCTX_INPROC_SERVER = 1

Enumeration 0 ; SpeechVoiceSpeakFlags
  #SVSFDefault          = 0
  #SVSFlagsAsync        = 1
  #SVSFPurgeBeforeSpeak = 2
  #SVSFIsFilename       = 4
  #SVSFIsXML            = 8
  #SVSFIsNotXML         = 16
  #SVSFPersistXML       = 32
  #SVSFNLPSpeakPunc     = 64
  #SVSFNLPMask          = 64
  #SVSFVoiceMask        = 127
  #SVSFUnusedFlags      = -128
EndEnumeration

Import "ole32.lib"
  CoInitialize(reserved.l = #Null)
  CoUninitialize()
  CLSIDFromProgID(ProgID.p-bstr, *clsid.CLSID)
  CLSIDFromString(String.p-bstr, *clsid.CLSID)
EndImport

Interface ISpeechVoice Extends IDispatch
  get_Status(*ISpeechVoiceStatus.l)
  get_Voice(*ISpeechObjectToken.l)
  put_Voice(*ISpeechObjectToken.l)
  get_AudioOutput(*ISpeechObjectToken.l)
  put_AudioOutput(*ISpeechObjectToken.l)
  get_AudioOutputStream(*ISpeechBaseStream.l)
  put_AudioOutputStream(*ISpeechBaseStream.l)
  get_Rate(long.l)
  put_Rate(long.l)
  get_Volume(long.l)
  put_Volume(long.l)
  put_AllowAudioOutputFormatChangesOnNextSet(VARIANT_BOOL.l)
  get_AllowAudioOutputFormatChangesOnNextSet(VARIANT_BOOL.l)
  get_EventInterests(SpeechVoiceEvents.l)
  put_EventInterests(SpeechVoiceEvents.l)
  put_Priority(SpeechVoicePriority.l)
  get_Priority(SpeechVoicePriority.l)
  put_AlertBoundary(SpeechVoiceEvents.l)
  get_AlertBoundary(SpeechVoiceEvents.l)
  put_SynchronousSpeakTimeout(long.l)
  SynchronousSpeakTimeout(long.l)
  Speak(Text.p-bstr, SpeechVoiceSpeakFlags.l, long.l)
  SpeakStream(*ISpeechBaseStream, SpeechVoiceSpeakFlags.l, long.l)
  Pause()
  Resume()
  Skip(*Type, NumItems.l, long.l)
  GetVoices(*RequiredAttributes.l, *OptionalAttributes, *ISpeechObjectTokens.l)
  GetAudioOutputs(*RequiredAttributes, *OptionalAttributes, *ISpeechObjectTokens.l)
  WaitUntilDone(msTimeout.l, VARIANT_BOOL.l)
  SpeakCompleteEvent(long.l)
  IsUISupported(*TypeOfUI, *ExtraData.VARIANT, VARIANT_BOOL.l)
  DisplayUI(hWndParent.l, *Title, *TypeOfUI, *ExtraData.VARIANT)
EndInterface
Interface ISpeechObjectToken Extends IDispatch
  get_Id(ObjectId)
  get_DataKey(ISpeechDataKey.l)
  get_Category(ISpeechObjectTokenCategory.l)
  GetDescription(Locale.l, Description)
  SetId(id, CategoryID, CreateIfNotExist)
  GetAttribute(AttributeName.p-bstr, *AttributeValue)
  CreateInstance(pUnkOuter, SpeechTokenContext, Object)
  Remove(ObjectStorageCLSID)
  GetStorageFileName(ObjectStorageCLSID, KeyName, FileName, SpeechTokenShellFolder, *FilePath)
  RemoveStorageFileName(ObjectStorageCLSID, KeyName, DeleteFile)
  IsUISupported(TypeOfUI, *ExtraData, *Object, *Supported)
  DisplayUI(hwnd, Title, TypeOfUI, *ExtraData, *Object)
  MatchesAttributes(Attributes, *Matches)
EndInterface
Interface ISpeechObjectTokens Extends IDispatch
  get_Count(a.l)
  Item(Index.l, Token.ISpeechObjectToken)
  get__NewEnum(ppEnumVARIANT.IUnknown )
EndInterface

Procedure.l Speak2(*SpeechVoice.ISpeechVoice, *SpeechObjectTokens.ISpeechObjectTokens, Text.s, Rate.l = 0, Voice.l = 0)
 
  Protected flag.l = #SVSFDefault, Token.ISpeechObjectToken
 
  If *SpeechObjectTokens\Item(Voice, @Token) = #S_OK
    *SpeechVoice\put_Voice(Token)
    *SpeechVoice\put_Rate(Rate)
    *SpeechVoice\Speak(Text, 0, @flag)
  EndIf
 
EndProcedure

Procedure.l SpeakBase64(*SpeechVoice.ISpeechVoice, *SpeechObjectTokens.ISpeechObjectTokens, TextBase64.s, Rate.l = 0, Voice.l = 0)
 
  Protected Text.s = Space(Len(TextBase64))
 
  Speak2(*SpeechVoice, *SpeechObjectTokens, Left(Text, Base64Decoder(@TextBase64, Len(TextBase64), @Text, Len(Text))), Rate, Voice)
 
EndProcedure

If CLSIDFromProgID("SAPI.SpVoice", @clsid.CLSID) = #S_OK
 
  If CLSIDFromString("{269316D8-57BD-11D2-9EEE-00C04F797396}", @Refiid.CLSID) = #S_OK
   
    CoInitialize()
   
    If  CoCreateInstance_(clsid, #Null, #CLSCTX_INPROC_SERVER, Refiid, @SpeechVoice.ISpeechVoice) = #S_OK       
     
      ; Listing des voix installés
     
      ; Voice[0] = Microsoft Sam, 409;9
      ; Voice[1] = LH Veronique, 40C
      ; Voice[2] = LH Pierre, 40C
     
      SpeechVoice\GetVoices(0, 0, @SpeechObjectTokens.ISpeechObjectTokens)
      SpeechObjectTokens\get_Count(@Count)
     
      VoiceList.s = ""
     
      For i = 0 To Count - 1
        SpeechObjectTokens\Item(i, @Token.ISpeechObjectToken)
        Token\GetDescription(0, @Description)
        Token\GetAttribute("Language", @AttributeValue)
        VoiceList + "Voice[" + Str(i) + "].Description = " + PeekS(Description, -1, #PB_Unicode) + #LF$
        VoiceList + "Voice[" + Str(i) + "].Language = " + PeekS(AttributeValue, -1, #PB_Unicode) + #LF$
        Token\Release()
      Next
     
      MessageRequester("Information", VoiceList)
     
      ; Joue quelques phrases
     
      Speak2(SpeechVoice, SpeechObjectTokens, "Pardon pour ces quelques gros mots mais c'est trop rigolo !", 0, 0)
      SpeakBase64(SpeechVoice, SpeechObjectTokens, "VmEgdGUgZmFpcmUgZm91dHJlIGNvbm5hcmQsIGVzcOhjZSBkJ2VuY3Vs6SwgZ3JvcyBtZXJkZXV4LCBwYXV2cmUgY29uLCBncm9zIGTpYmlsZSwgYWJydXRpLCBncm9zIGN1bCBwbGVpbiBkZSBtZXJkZSAh", 1, 0)
      Speak2(SpeechVoice, SpeechObjectTokens, "Ah ah ah ah ha t'es trop con!", 1, 0)
     
      ; Libération des ressources
     
      SpeechObjectTokens\Release()
      SpeechVoice\Release()
     
    EndIf
   
    CoUninitialize()
   
  EndIf
 
EndIf

; 
; EPB 

Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Library Speak_lib

Post by dobro »

here Virginie an Reader of Clipboard

prg which implements the above book ...

you select a sentence (or a text) to read, and Control+C ->copy to clipboard
then you click on the button [Speak]

first, choose a voice
adjust the playback speed,
adjust the pitch

:)

Code: Select all

; Virginie By Dobro 
; an Reader of Clipboard
Declare MyStopEvent() 
Declare MyStartEvent()
Declare MyPositionEvent(letter.l) 

Enumeration
	#Fenetre
	#liste
	#bouton_parle
	#text 
	#text2
	#text3
	#text4
	#Vitesse
	#fichier
	#volume
	#pitch
EndEnumeration


global param$
global voix$=getvoix( ) 
global nombre = Val(StringField(voix$,1,","))+1
global Name$ ; the nameof voice
;voices.l = TTSEngCount() ; Get the highest voice index.
If nombre > -1 ; If there are any voice installed...
	Debug "There are "+Str(nombre-1)+" voices installed in your system"
	
	
	; ************ just for control ****************************
	For i=2 To nombre
		name$=StringField(voix$,i,",") ;TTSEngName(i) ; Retrieve each voice name. 
		Debug "Voice index = "+Str(i)+" , Voice name = "+name$
	Next i 
	Else 
	MessageRequester("erreur","je ne trouve pas de voix"+Chr(10)+"installé sur le system",#PB_MessageRequester_Ok )
	End 
EndIf
; ******************************************************************

;{**********lit le reglage*****************
OpenPreferences (GetCurrentDirectory()+"init.prefs")
PreferenceGroup("Global")
param$=readPreferenceString("voix", "eSpeak-en")
vitesse$=readPreferenceString("Vitesse", "-50")
volume$=readPreferenceString("Volume", "100")
pitch$=readPreferenceString("pitch",  "10")
ClosePreferences()
global voix=Val(param$)
global vitesse=Val(vitesse$)
global volume=Val(volume$)
global pitch=Val(pitch$)

;}***************************

;For i=0 To voix
name$=StringField(voix$,voix+1,",") ;TTSEngName(i) ; Retrieve each voice name. 
Debug "Voice index = "+Str(i)+" , Voice name = "+name$
debug "*******************"
; Next i 


;TTSSelect(voix) ; choisi la voix sauvé

;TTSSpeak("Bonjour") ; Speak! 
Speak(name$,"Bonjour",volume,vitesse,pitch) 

OpenWindow( #Fenetre, 374, 121, 200, 180,name$,  #PB_Window_SystemMenu | #PB_Window_TitleBar  )
SetWindowPos_(WindowID( #Fenetre), -1, 230, 230, 0, 0, #SWP_NOSIZE )

;{ ***** dessin de l'interface **********************

; bouton parle/stop
;CreateGadgetList(WindowID(#Fenetre))
ButtonGadget(#bouton_parle, 5, 25, 120, 40, "Parle")
Resultat = ComboBoxGadget(#liste, 5, 2, 150,20)

; liste des voix
For i=2 To nombre
	name$=StringField(voix$,i,",") ;TTSEngName(i) ; Retrieve each voice name. 
	;Debug "Voice index = "+Str(i)+" , Voice name = "+name$
	AddGadgetItem(#liste, -1,name$ ) ; ajoute dans la liste les noms trouvé+nationalité
	Debug "Voice index = "+Str(i-1)+" , Voice name = "+name$
Next i 

SetGadgetState(#liste, voix-1) ; active la voix lu par defaut dans la liste
name$=GetGadgetText(#liste)
SetWindowTitle(#fenetre, name$) ; change le titre de la fenetre



; tracbar horizontal (vitesse de la voix)
TextGadget(#text2 , 2,70, 50, 15, "Vitesse" )
Resultat = TrackBarGadget(#vitesse, 40, 65, 100, 50,0, 12,#PB_TrackBar_Ticks   )
SetGadgetState(#vitesse, vitesse+6)

; tracbar horizontal (volume de la voix)
TextGadget(#text3 , 2,120, 50, 15, "Volume" )
Resultat = TrackBarGadget(#volume, 40, 110, 100, 50, 0,100 ,#PB_TrackBar_Ticks  )
SetGadgetState(#volume, volume)

; tracbar vertical (pitch)
TextGadget(#text4 , 160,145, 50, 30, "pitch" )
Resultat = TrackBarGadget(#pitch, 160, 50, 50, 100, 0,20,#PB_TrackBar_Vertical )
SetGadgetState(#pitch, pitch)




TextGadget(#text , 2,155, 150, 15, "By Dobro" ,#PB_Gadget_FrontColor)
SetGadgetColor(#text , #PB_Gadget_FrontColor,  RGB($42,$42,$FF))

;} ***************************************************

Repeat
	EventID = WaitWindowEvent() 
	Select EventID
		Case #PB_Event_Gadget
		Select EventGadget()
			Case #bouton_parle  ; apuis sur le bouton parle
			text$ = GetClipboardText() 
			
			pitch= GetGadgetState(#pitch)
			volume= GetGadgetState(#volume)
			vitesse= GetGadgetState(#vitesse) -6
			
			; virginie speak , remove the Smiley of Forum ...
			text$ = RemoveString(text$, "Very Happy" ,1)
			text$ = RemoveString(text$, "Crying or Very sad" ,1)
			text$ = RemoveString(text$, "Smile" ,1)
			text$ = RemoveString(text$, "Sad" ,1)
			text$ = RemoveString(text$, "Surprised" ,1)
			text$ = RemoveString(text$, "Shocked" ,1)
			text$ = RemoveString(text$, "Confused" ,1)
			text$ = RemoveString(text$, "Cool" ,1)
			text$ = RemoveString(text$, "Laughing" ,1)
			text$ = RemoveString(text$, "Mad" ,1)
			text$ = RemoveString(text$, "#Mad" ,1)
			text$ = RemoveString(text$, "Razz" ,1)
			text$ = RemoveString(text$, "Embarassed" ,1) 
			text$ = RemoveString(text$, "#evil" ,1)
			text$ = RemoveString(text$, "Twisted Evil" ,1)
			text$ = RemoveString(text$, "Rolling Eyes" ,1) 
			text$ = RemoveString(text$, "Wink" ,1)
			text$ = RemoveString(text$, "Exclamation" ,1)
			text$ = RemoveString(text$, "Question" ,1)
			text$ = RemoveString(text$, "Idea" ,1) 
			;        TTSSpeak(text$) ; Speak!  
			speak(name$,text$,volume,vitesse,pitch)
			
			
			Case #vitesse 
			Case #liste ; choix dans la liste combo
			voix = GetGadgetState(#liste) 
			name$=GetGadgetText(#liste)
			SetWindowTitle( #fenetre, name$)  
			fin:
		EndSelect 
	EndSelect
Until EventID = #PB_Event_CloseWindow

;{**********Sauve le reglage*****************

CreatePreferences(GetCurrentDirectory()+"init.prefs")
PreferenceGroup("Global")
WritePreferenceString("voix", Str(voix+1))
WritePreferenceString("Vitesse", Str(vitesse))
WritePreferenceString("Volume", Str(volume))
WritePreferenceString("pitch",  Str(pitch))
ClosePreferences()


;}***************************

speak(name$,"au revoir",volume,vitesse,pitch)


End

; EPB

Last edited by dobro on Fri Aug 24, 2012 4:52 pm, edited 1 time in total.
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
User avatar
VB6_to_PBx
Enthusiast
Enthusiast
Posts: 627
Joined: Mon May 09, 2011 9:36 am

Re: Library Speak_lib

Post by VB6_to_PBx »

these Voices are all working for me,
tested on WIN-7-32bit and WIN-7-64bit computers

Code: Select all

;        Speak(the name of the voice$,say the sentence$,Volume ,Speed Diction,Pitch)
;        **********************************************************************************
Speak( "Crystal16" , "hello , i am Crystal , what can i speak for you ?" , 100, 1, 150)
Speak( "Mike16" , "hello , i am Mike , what can i speak for you ?" , 100, 1, 150)
Speak( "IVONA Brian" , "hello , i am IVONA Brian , what can i speak for you ?" , 100, 1, 150)
Speak( "IVONA 2 Amy" , "hello , i am IVONA Amy , what can i speak for you ?" , 100, 1, 150)
Speak( "LH Michael" , "hello , i am Michael , what can i speak for you ?" , 100, 1, 150)
Speak( "LH Michelle" , "hello , i am Michelle , what can i speak for you ?" , 100, 1, 150)
Speak( "Microsoft Anna" , "hello , i am Microsoft Anna , what can i speak for you ?" , 100, 1, 150)
 
PureBasic .... making tiny electrons do what you want !

"With every mistake we must surely be learning" - George Harrison
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Library Speak_lib

Post by dobro »

fine :)
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
morosh
Enthusiast
Enthusiast
Posts: 329
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: Library Speak_lib

Post by morosh »

very interesting, hope a unicode version soon

thanks a lot
PureBasic: Surprisingly simple, diabolically powerful
User avatar
dobro
Enthusiast
Enthusiast
Posts: 766
Joined: Sun Oct 31, 2004 10:54 am
Location: France
Contact:

Re: Library Speak_lib

Post by dobro »

morosh wrote:very interesting, hope a unicode version soon

thanks a lot

This version operates in normal mode AND unicode

however, refuses to compile Tailbite .... :?
I do not understand why, since this library, work in the editor .. :shock:

you can always use standard procedures ;)

Syntax :

voix$=getvoix( ) ; return : "returns the number of name_of_voices,name_of_voice1,name_of_voice2,name_of_voice3,....)

Speak2(name_of_voice$,sentence$,Volume (min 0//max 100),Speed_diction (min-6//max 6) ,Pitch (min -10//max 20) )





Code: Select all


global VoiceList.s

Import "ole32.lib"
	CoInitialize(reserved.l = #Null)
	CoUninitialize()
	CLSIDFromProgID(ProgID.p-bstr, *clsid.CLSID)
	CLSIDFromString(String.p-bstr, *clsid.CLSID)
EndImport



#CLSCTX_INPROC_SERVER = 1

Enumeration 0 ; SpeechVoiceSpeakFlags
	#SVSFDefault          = 0
	#SVSFlagsAsync        = 1
	#SVSFPurgeBeforeSpeak = 2
	#SVSFIsFilename       = 4
	#SVSFIsXML            = 8
	#SVSFIsNotXML         = 16
	#SVSFPersistXML       = 32
	#SVSFNLPSpeakPunc     = 64
	#SVSFNLPMask          = 64
	#SVSFVoiceMask        = 127
	#SVSFUnusedFlags      = -128
EndEnumeration


Interface ISpeechVoice Extends IDispatch
	get_Status(*ISpeechVoiceStatus.l)
	get_Voice(*ISpeechObjectToken.l)
	put_Voice(*ISpeechObjectToken.l)
	get_AudioOutput(*ISpeechObjectToken.l)
	put_AudioOutput(*ISpeechObjectToken.l)
	get_AudioOutputStream(*ISpeechBaseStream.l)
	put_AudioOutputStream(*ISpeechBaseStream.l)
	get_Rate(long.l)
	put_Rate(long.l)
	get_Volume(long.l)
	put_Volume(long.l)
	put_AllowAudioOutputFormatChangesOnNextSet(VARIANT_BOOL.l)
	get_AllowAudioOutputFormatChangesOnNextSet(VARIANT_BOOL.l)
	get_EventInterests(SpeechVoiceEvents.l)
	put_EventInterests(SpeechVoiceEvents.l)
	put_Priority(SpeechVoicePriority.l)
	get_Priority(SpeechVoicePriority.l)
	put_AlertBoundary(SpeechVoiceEvents.l)
	get_AlertBoundary(SpeechVoiceEvents.l)
	put_SynchronousSpeakTimeout(long.l)
	SynchronousSpeakTimeout(long.l)
	Speak(Text.p-bstr, SpeechVoiceSpeakFlags.l, long.l)
	SpeakStream(*ISpeechBaseStream, SpeechVoiceSpeakFlags.l, long.l)
	Pause()
	Resume()
	Skip(*Type, NumItems.l, long.l)
	GetVoices(*RequiredAttributes.l, *OptionalAttributes, *ISpeechObjectTokens.l)
	GetAudioOutputs(*RequiredAttributes, *OptionalAttributes, *ISpeechObjectTokens.l)
	WaitUntilDone(msTimeout.l, VARIANT_BOOL.l)
	SpeakCompleteEvent(long.l)
	IsUISupported(*TypeOfUI, *ExtraData.VARIANT, VARIANT_BOOL.l)
	DisplayUI(hWndParent.l, *Title, *TypeOfUI, *ExtraData.VARIANT)
EndInterface
Interface ISpeechObjectToken Extends IDispatch
	get_Id(ObjectId)
	get_DataKey(ISpeechDataKey.l)
	get_Category(ISpeechObjectTokenCategory.l)
	GetDescription(Locale.l, Description)
	SetId(id, CategoryID, CreateIfNotExist)
	GetAttribute(AttributeName.p-bstr, *AttributeValue)
	CreateInstance(pUnkOuter, SpeechTokenContext, Object)
	Remove(ObjectStorageCLSID)
	GetStorageFileName(ObjectStorageCLSID, KeyName, FileName, SpeechTokenShellFolder, *FilePath)
	RemoveStorageFileName(ObjectStorageCLSID, KeyName, DeleteFile)
	IsUISupported(TypeOfUI, *ExtraData, *Object, *Supported)
	DisplayUI(hwnd, Title, TypeOfUI, *ExtraData, *Object)
	MatchesAttributes(Attributes, *Matches)
EndInterface
Interface ISpeechObjectTokens Extends IDispatch
	get_Count(a.l)
	Item(Index.l, Token.ISpeechObjectToken)
	get__NewEnum(ppEnumVARIANT.IUnknown )
EndInterface


Procedure.l Speak(*SpeechVoice.ISpeechVoice, *SpeechObjectTokens.ISpeechObjectTokens, Text.s, Rate.l = 0, Voice.l = 0,Volume=100)
	Protected flag.l = #SVSFDefault, Token.ISpeechObjectToken
	If *SpeechObjectTokens\Item(Voice, @Token) = #S_OK
*SpeechVoice\put_Volume(volume)
		*SpeechVoice\put_Voice(Token)
		*SpeechVoice\put_Rate(Rate)
		*SpeechVoice\Speak(Text, 0, @flag)
	EndIf
EndProcedure



ProcedureDLL Speak2(voix$,text$,volume=100,Vitesse=0,Pitch=0)
	If voix$<>""
		vox.s="<voice required="+Chr(34)+"Name="+ voix$+Chr(34)+"/>"+"<pitch absmiddle="+Chr(34)+Str(pitch)+Chr(34)+"/>" 
		Else
		vox.s=""
	EndIf
	If CLSIDFromProgID("SAPI.SpVoice", @clsid.CLSID) = #S_OK
		If CLSIDFromString("{269316D8-57BD-11D2-9EEE-00C04F797396}", @Refiid.CLSID) = #S_OK
			CoInitialize()
			If  CoCreateInstance_(clsid, #Null, #CLSCTX_INPROC_SERVER, Refiid, @SpeechVoice.ISpeechVoice) = #S_OK    
				SpeechVoice\GetVoices(0, 0, @SpeechObjectTokens.ISpeechObjectTokens)
				SpeechObjectTokens\get_Count(@Count)
				Speak(SpeechVoice, SpeechObjectTokens, vox.s+text$, vitesse, 0,volume)
				SpeechObjectTokens\Release()
				SpeechVoice\Release()
			EndIf
			CoUninitialize()
		EndIf
	EndIf
EndProcedure
;
procedureDLL.s  getvoix( )
	If CLSIDFromProgID("SAPI.SpVoice", @clsid.CLSID) = #S_OK
		If CLSIDFromString("{269316D8-57BD-11D2-9EEE-00C04F797396}", @Refiid.CLSID) = #S_OK
			CoInitialize()
			If  CoCreateInstance_(clsid, #Null, #CLSCTX_INPROC_SERVER, Refiid, @SpeechVoice.ISpeechVoice) = #S_OK       
				SpeechVoice\GetVoices(0, 0, @SpeechObjectTokens.ISpeechObjectTokens)
				SpeechObjectTokens\get_Count(@Count)
				VoiceList.s = ""
				VoiceList =str(count)+","
				For i = 0 To Count - 1
					SpeechObjectTokens\Item(i, @Token.ISpeechObjectToken)
					Token\GetDescription(0, @Description)
					Token\GetAttribute("Language", @AttributeValue)
					VoiceList+ PeekS(Description, -1, #PB_Unicode) + ","
					;;;;;;;VoiceList + "Voice[" + Str(i) + "].Language = " + PeekS(AttributeValue, -1, #PB_Unicode) + #LF$
					Token\Release()
				Next i
				SpeechObjectTokens\Release()
				SpeechVoice\Release()
			EndIf
			CoUninitialize()
		EndIf
	endif
	ProcedureReturn VoiceList.s
EndProcedure



; ******************************************************************************************************************
; ******************************************************************************************************************
; ******************************** Example to use *********************************************************************

voix$=getvoix( ) ; on recupere le nombre et le nom des voix installé  ////////  Grab Voices on systeme
; getvoix() retourne une chaine "nbr_de_voix,voix1$,voix2$,voix3$........ etc "

nombre = Val(StringField(voix$,1,",")) ; recupere le nombre de voix installé (premier element de la chaine) ; //// number voices on system
voix$=Right(voix$,Len(voix$)-2) ; on retire le nombre de voix, et sa virgule de la liste des noms de voix

debug " List Of Voices "
For i=1 To nombre ;
	Debug StringField(voix$,i,",") ; ressort tout les noms des voix installées ////////// print name of voices
Next i


; 
Speak2("eSpeak-EN","hello my Friend",100,-2,150)  ; if the voice Espeak installed  ; it say "hello my Friend"


; ******************************************************************************************************************
; ******************************************************************************************************************


; EPB


Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/
morosh
Enthusiast
Enthusiast
Posts: 329
Joined: Wed Aug 03, 2011 4:52 am
Location: Beirut, Lebanon

Re: Library Speak_lib

Post by morosh »

Yes exactly, I noticed that.
the problem comes from TailBite

thanks
PureBasic: Surprisingly simple, diabolically powerful
Post Reply