Author
Topic: CLR - Text 2 Speech (Read 4589 times)

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.

Code: Winbatch

;***************************************************************************;** Playing Around with CLR speech [default voice];**;** Reference: ;** REQUIRES WinBatch 2013A or newer & CLR version 4.0 ;**;** Stan LittleField, June 29,2013;*************************************************************************** IfVersion()<'2013A'Pause('Notice', 'Need 2013A or Newer Version of WinBatch')ExitEndIfObjectClrOption("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 AnnacVoice =""cName=oSpeech.Voice.NamecVoice=cVoice:"Name: ":cName:@CRLFcVoice=cVoice:"Culture: ":oSpeech.Voice.Culture:@CRLFcVoice=cVoice:"Age: ":oSpeech.Voice.Age:@CRLFcVoice=cVoice:"Gender: ":oSpeech.Voice.Gender:@CRLFcVoice=cVoice:"Description: ":oSpeech.Voice.Description:@CRLFcVoice=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:@CRLFoSpeech.SelectVoice(cName)oSpeech.Speak("This is a Test")oSpeech.Dispose()oSpeech=0Message("",cVoice)Exit;////////////////////////////////////////////////////////////////////////////////////////////////////[code=WINBATCH];***************************************************************************;** Playing Around with CLR speech;**;** Reference: ;** REQUIRES WinBatch 2013A or newer & CLR version 4.0 ;**;** Stan LittleField, June 29,2013;*************************************************************************** IfVersion()<'2013A'Pause('Notice', 'Need 2013A or Newer Version of WinBatch')ExitEndIfObjectClrOption("use","System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");create an object for the class that controls speechoSpeech =ObjectClrNew('System.Speech.Synthesis.SpeechSynthesizer')cVoices =""ForEach v In oSpeech.GetInstalledVoices() info = v.VoiceInfo cVoices=cVoices:info.Name:@TABNextn=ItemCount(cVoices,@TAB)-1Message(n,cVoices)For i=1To n oSpeech.SelectVoice(ItemExtract(i,cVoices,@TAB)) oSpeech.Speak("This is a Test")TimeDelay(1)NextoSpeech.Dispose()oSpeech=0Exit;//////////////////////////////////////////////////////////////////////////////////////////////////

Interesting. I wanted to test on my Windows XP System. One difference is that the default voice is Sam instead of Anna.

Yes, XP has 2 or 3 voices and I believe uses a different SAPI version. I got Dragon Naturally Speaking thinking you could create your own 'voice' for text 2 speech. This sitehttp://www.zero2000.com/free-text-to-speech-natural-voices.htmllists several 'free' voices, but I was lead to believe the site could not be trusted, so I'm stuck with Anna.