Publié : mer. 18/juil./2007 20:16
Code : Tout sélectionner
; Une partie du code à été écrit par Sapero avec le language Aurora Compiler
; Traduit en Purebasic By Nico
#CLSCTX_INPROC_SERVER=1
;/Valeur pour SpeechVoiceSpeakFlags
#SVSFDefault = 0
#SVSFlagsAsync = 1
#SVSFPurgeBeforeSpeak = 2
#SVSFIsFilename = 4
#SVSFIsXML = 8
#SVSFIsNotXML = 16
#SVSFPersistXML = 32
#SVSFNLPSpeakPunc = 64
#SVSFNLPMask = 64
#SVSFVoiceMask = 127
#SVSFUnusedFlags = -128
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,*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
Interface ISpeechVoice Extends IDispatch
get_Status(*ISpeechVoiceStatus .l)
get_Voice(*ISpeechObjectToken)
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
Texte1.s="SAPI.SpVoice"
*Tampon1=AllocateMemory((Len(Texte1)+1)*2)
PokeS(*Tampon1,Texte1,-1,#PB_Unicode)
Texte2.s="{269316D8-57BD-11D2-9EEE-00C04F797396}"
*Tampon2=AllocateMemory((Len(Texte2)+1)*2)
PokeS(*Tampon2,Texte2,-1,#PB_Unicode)
If CLSIDFromProgID_(*Tampon1, @Clsid.CLSID)=#S_OK
If CLSIDFromString_(*Tampon2, @Refiid.CLSID)=#S_OK
CoInitialize_(0)
If CoCreateInstance_(Clsid, #Null, #CLSCTX_INPROC_SERVER, Refiid, @SpeechVoice.ISpeechVoice)=#S_OK
SpeechVoice\GetVoices(0, 0, @SpeechObjectTokens.ISpeechObjectTokens)
SpeechObjectTokens\get_Count(@Count)
;Listing des voix installés
For a= 0 To Count-1
SpeechObjectTokens\Item(a,@Token.ISpeechObjectToken)
Token\GetDescription(0,@Description)
Debug PeekS(Description,-1,#PB_Unicode)
Token\Release()
Next
; Je choisit la voix 1, commence à 0
SpeechObjectTokens\Item(1,@Token.ISpeechObjectToken)
SpeechVoice\put_Voice(Token)
SpeechObjectTokens\Release()
Texte3.s="PureBasic! is very nice"
*Tampon3=AllocateMemory((Len(Texte3)+1)*2)
PokeS(*Tampon3,Texte3,-1,#PB_Unicode)
temp=#SVSFDefault
bstrText = SysAllocString_(*Tampon3)
SpeechVoice\Speak(bstrText, 0, @temp)
SysFreeString_(bstrText)
FreeMemory(*Tampon3)
SpeechVoice\Release()
EndIf
CoUninitialize_()
EndIf
EndIf
FreeMemory(*Tampon1)
FreeMemory(*Tampon2)
End