J'ai récupéré ce programme du forum et j'ai remarqué que la synthèse vocale SAPI, voix française ne marche pas en mode x64, Par contre ça marche bien en mode x86. La voix anglaise marche bien en x64 et en x86. Quelqu'un a déjà rencontré ça? y-a-t'il un remède?
J'utilise PB6-beta3 (normal non backend-C), et comme voix française j'ai "ScanSoft Virginie_Dri40_16kHz" installée
Merci d'avance
Code : Tout sélectionner
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.s GetWoix( )
Define clsid.CLSID, Refiid.CLSID, SpeechVoice.ISpeechVoice, SpeechObjectTokens.ISpeechObjectTokens
Define Count.l, i.l, Token.ISpeechObjectToken, Description.l, AttributeValue.l
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
ProcedureDLL Speak2(voix$,text$,volume=100,Vitesse=0,Pitch=0)
Define vox.s, clsid.CLSID, Refiid.CLSID, SpeechVoice.ISpeechVoice, SpeechObjectTokens.ISpeechObjectTokens
Define Count.l
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
voix$=GetWoix( ) ; 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( "ScanSoft Virginie_Dri40_16kHz" , "Bonjour" , 100, -1, 150)
Speak2( "Microsoft David Desktop" , "hello" , 100, -2, 150)