Advertisement
DanielTheGeek

Simple Text-To-Speech program with custom validation

Feb 25th, 2016
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim msg, dgeek, oFileStream, oVoice, i, text
  2. dim filesys, newfolder
  3.  
  4. Const SAFT48kHz16BitStereo = 39
  5. Const SSFMCreateForWrite = 3 'creates the wav file even if it is present in our folder
  6.  
  7. Set dgeek=CreateObject("sapi.spvoice")
  8.     i=hour(time)  'custom greeting
  9.         if i < 12 Then
  10.             i=("Good morning, I am Susy, Speech expert created by Daniel the geek")
  11.             dgeek.Speak i
  12.             Else
  13.                 i=("Good day, I am Susy, Speech expert created by Daniel the geek")
  14.         End If
  15.  
  16. text=msgBox("Welcome - Dann v0.0.1 Text to audio converter")
  17.  
  18. msg=InputBox("Enter your text for conversion","Dann v0.0.1 Text to audio converter")
  19.  
  20.     If msg = ("Fuck") Then 'word filtering add your preffered words
  21.         Err.Clear
  22.         Wscript.Echo ("F words are not allowed, this response was trigerred because you entered an F word into the text field") 'display the rules
  23.         Else If msg = ("") Then 'setting a response if no text has been entered
  24.             dgeek.Speak ("You did not type anything for me to say, check back later, since your mind is blank")
  25.             dgeek.WaitUntilDone(1000)
  26.             Else
  27.                 dgeek.Speak msg
  28.     End If
  29.     End If
  30.  
  31. 'creating a folder to export the sound file to
  32. set filesys=CreateObject("Scripting.FileSystemObject")
  33. 'checking if the folder does not exist
  34. If Not
  35. filesys.FolderExists("c:\Danntextaudio\rec\") Then
  36. newfolder = filesys.CreateFolder("c:\Danntextaudio\rec\") 'creating a custom folder
  37.  
  38. Wscript.Echo ("A new folder '" newfolder "' has been created") 'alerting user about the new folder
  39. End If
  40.  
  41. 'Saving the text entered as a wav
  42.  
  43. Set oFileStream = CreateObject("SAPI.SpFileStream")
  44.  
  45. oFileStream.Format.Type = SAFT48kHz16BitStereo
  46. oFileStream.Open "C:\Danntextaudio\rec\recording.wav", SSFMCreateForWrite
  47.  
  48. Set oVoice = CreateObject("SAPI.SpVoice")
  49. Set oVoice.AudioOutputStream = oFileStream
  50. oVoice.Speak msg
  51. oVoice.WaitUntilDone(10000)
  52.  
  53. oFileStream.Close
  54.  
  55.  
  56. 'I posted this as a guest before but discovered a little error. So here is an update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement