J'ai fait quelque recherche sur le sujet, déjà il te faudra des droits sur l'ordi que tu utilises car il faut installer la voix française (je l'ai mise ici >
).
".
Code : Tout sélectionner
; Ce code à été écrit par Sapero avec le language Aurora Compiler
; Traduit en Purebasic By Nico
; ****************************************************************************
; ****************************************************************************
EnableExplicit
; ****************************************************************************
; ****************************************************************************
; VALMEUR POUR "SpeechVoiceSpeakFlags".
Enumeration
#SVSFDefault = 0
#SVSFlagsAsync = 1
#SVSFPurgeBeforeSpeak = 2
#SVSFIsFilename = 4
#SVSFIsXML = 8
#SVSFIsNotXML = 16
#SVSFPersistXML = 32
#SVSFNLPSpeakPunc = 64
#SVSFNLPMask = 64
#SVSFVoiceMask = 127
#SVSFUnusedFlags = -128
EndEnumeration
Enumeration
#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)
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, 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
; ****************************************************************************
; ****************************************************************************
Procedure.b isSAPIInstalled()
; VERIFICATION DE L'INSTALLATION DE SAPI 4 OU 5.
Define a.i
Define bresult.b = #False
CoInitialize_(0)
If CoCreateInstance_(?CLSID_SpVoice, 0,#CLSCTX_ALL, ?IID_ISpVoice, @a) = 0
bresult = #True
EndIf
If CoCreateInstance_(?CLSID_ITextToSpeech, 0,#CLSCTX_ALL, ?IID_ITextToSpeech, @a) = 0
bresult = #True
EndIf
CoUninitialize_()
ProcedureReturn bresult
EndProcedure
; ****************************************************************************
; ****************************************************************************
Procedure SAPISpeechtext(stext.s)
;
Define.i itemp, bstrtext
Define text1.s
Define *buffer1, *buffer2, *buffer3
Define clsid.CLSID, refiid.CLSID
Define speechvoice.ISpeechVoice
If isSAPIInstalled() = #True And stext <> #NULL$
text1 = "SAPI.SpVoice"
*buffer1 = AllocateMemory((Len(text1) + 1) * 2)
PokeS(*buffer1, text1, -1, #PB_Unicode)
text1 = "{269316D8-57BD-11D2-9EEE-00C04F797396}"
*buffer2 = AllocateMemory((Len(text1) + 1) * 2)
PokeS(*buffer2, text1, -1, #PB_Unicode)
If CLSIDFromProgID_(*buffer1, @Clsid.clsid) = #S_OK
If CLSIDFromString_(*buffer2, @Refiid.clsid) = #S_OK
CoInitialize_(0)
If CoCreateInstance_(clsid, #Null, #CLSCTX_INPROC_SERVER, refiid, @speechvoice) = #S_OK
*buffer3 = AllocateMemory((Len(stext) + 1) * 2)
PokeS(*buffer3, stext, -1, #PB_Unicode)
itemp = #SVSFDefault
bstrtext = SysAllocString_(*buffer3)
;
; EXEMPLE DE QUELQUES PARAMATRES.
;
speechvoice\put_Rate(-5)
speechvoice\put_Volume(100)
;
; EXEMPLE DE QUELQUES PARAMATRES.
;
speechvoice\Speak(bstrtext, 0, @itemp)
SysFreeString_(bstrtext)
FreeMemory(*buffer3)
speechvoice\Release()
EndIf
CoUninitialize_()
EndIf
EndIf
FreeMemory(*buffer1)
FreeMemory(*buffer2)
EndIf
EndProcedure
SAPISpeechtext("Voila cela doit être en français")
End
; ****************************************************************************
; ****************************************************************************
DataSection
CLSID_SpVoice:
Data.l $96749377
Data.w $3391,$11D2
Data.b $9E,$E3,$00,$C0,$4F,$79,$73,$96
IID_ISpVoice:
Data.l $269316D8
Data.w $57BD,$11D2
Data.b $9E,$EE,$00,$C0,$4F,$79,$73,$96
CLSID_ITextToSpeech:
Data.l $EEE78591
Data.w $FE22,$11D0
Data.b $8B,$EF,$00,$60,$08,$18,$41,$DE
IID_ITextToSpeech:
Data.l $EEE78590
Data.w $FE22,$11D0
Data.b $8B,$EF,$00,$60,$08,$18,$41,$DE
EndDataSection