Advertisement
Combreal

winVoiceToWav.vbs

Mar 12th, 2019
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Const SapiFileType=18 ' Magic number, possibly voice specific (0 to 64)
  2.  
  3. strText=Trim(InputBox("What do you want me to say?","Listen to Sapi.SpFileStream.Format.Type Quality",""))
  4. If NOT len(strText)>0 Then WScript.Quit
  5. With CreateObject("Scripting.FileSystemObject")
  6.  strFile=.BuildPath(.GetParentFolderName(WScript.ScriptFullName),"Sapi.SpFileStream.Format.Type_"&SapiFileType&".wav")
  7.  If .FileExists(strFile) Then .DeleteFile strFile
  8. End With
  9. With CreateObject("Sapi.SpVoice")
  10.  Set ss=CreateObject("Sapi.SpFileStream")
  11.  ss.Format.Type=SapiFileType
  12.  ss.Open strFile,3,False
  13.  Set .AudioOutputStream=ss
  14.  .Speak strText,8
  15.  .waituntildone(-1)
  16.  ss.Close
  17.  Set ss=Nothing
  18. End With
  19. With CreateObject("WMPlayer.OCX"):.settings.autoStart=True:.settings.volume=100:.URL=strFile:Do until .playState=1:Wscript.Sleep 200:Loop:End With
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement