Again just practice playing around with different assemblies. IMHO the speech classes in .NET are fairly easy to navigate and incorporate into WB. I have attached two basic scripts. The first just looks at the default voice. The 2nd iterates all voices. My Win7 laptop only has Microsoft Anna so both scripts end up the same... but for anyone with multiple voices who can try the 2nd script I would appreciate feedback as to whether or not it works.
;***************************************************************************
;** Playing Around with CLR speech [default voice]
;**
;** Reference:
;** REQUIRES WinBatch 2013A or newer & CLR version 4.0
;**
;** Stan LittleField, June 29,2013
;***************************************************************************
If Version( )< '2013A'
Pause('Notice', 'Need 2013A or Newer Version of WinBatch')
Exit
EndIf
ObjectClrOption("use","System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
oSpeech = ObjectClrNew('System.Speech.Synthesis.SpeechSynthesizer')
;this is just the default voice, on Win7 it is Microsoft Anna
cVoice = ""
cName=oSpeech.Voice.Name
cVoice=cVoice:"Name: ":cName:@CRLF
cVoice=cVoice:"Culture: ":oSpeech.Voice.Culture:@CRLF
cVoice=cVoice:"Age: ":oSpeech.Voice.Age:@CRLF
cVoice=cVoice:"Gender: ":oSpeech.Voice.Gender:@CRLF
cVoice=cVoice:"Description: ":oSpeech.Voice.Description:@CRLF
cVoice=cVoice:"ID: ":oSpeech.Voice.Id:@CRLF
;this will obtain an object, you can iterate with a ForEach
;If oSpeech.Voice.SupportedAudioFormats.Count != 0 Then cVoice=cVoice:"Audio Formats: ":oSpeech.Voice.SupportedAudioFormats:@CRLF
oSpeech.SelectVoice(cName)
oSpeech.Speak("This is a Test")
oSpeech.Dispose()
oSpeech=0
Message("",cVoice)
Exit
;////////////////////////////////////////////////////////////////////////////////////////////////////
[code=WINBATCH]
;***************************************************************************
;** Playing Around with CLR speech
;**
;** Reference:
;** REQUIRES WinBatch 2013A or newer & CLR version 4.0
;**
;** Stan LittleField, June 29,2013
;***************************************************************************
If Version( )< '2013A'
Pause('Notice', 'Need 2013A or Newer Version of WinBatch')
Exit
EndIf
ObjectClrOption("use","System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
;create an object for the class that controls speech
oSpeech = ObjectClrNew('System.Speech.Synthesis.SpeechSynthesizer')
cVoices = ""
ForEach v In oSpeech.GetInstalledVoices()
info = v.VoiceInfo
cVoices=cVoices:info.Name:@TAB
Next
n=ItemCount(cVoices,@TAB)-1
Message(n,cVoices)
For i=1 To n
oSpeech.SelectVoice(ItemExtract(i,cVoices,@TAB))
oSpeech.Speak("This is a Test")
TimeDelay(1)
Next
oSpeech.Dispose()
oSpeech=0
Exit
;//////////////////////////////////////////////////////////////////////////////////////////////////
[/code]