Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,392 members, 7,819,404 topics. Date: Monday, 06 May 2024 at 03:45 PM

Simple Text-To-Speech Program using Vbscript. Do It Yourself. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Simple Text-To-Speech Program using Vbscript. Do It Yourself. (1629 Views)

Text To Voice Call Adverts At Www.text2voiceads.com/call @60 Naira / How To Create A Text To Speech Software With Notepad / Joomla: How To Link A Text To A Definite Joomla Category (2) (3) (4)

(1) (Reply)

Simple Text-To-Speech Program using Vbscript. Do It Yourself. by Nobody: 10:08am On Feb 25, 2016
I assume you know what a Text-To-Speech program does.

We are simply going to use SAPI (Speech Application Programming Interface), a Microsoft API for speech recognition on windows.

Let's dive right in:
Get yourself acquainted,

Dim is used to set a variable in vbscript, multiple variables can be declared with commas in front of them. Eg: dim one, two, three is the same as dim one, dim two, dim three.

Single quotes are what I used for commenting. Any thing that starts with a single quote is not part of the code.

Update:

I have not run that yet because I did the coding on my android tablet but I'm pretty sure it will work..

Plus make sure you save the code with a .vbs extension

If you are having problems copying the code, download it at http://pastebin.com/YJFw8MFC

Update 2:
Just found an error on the If Not statement...
Re: Simple Text-To-Speech Program using Vbscript. Do It Yourself. by Nobody: 10:10am On Feb 25, 2016
The code:

Dim msg, dgeek, oFileStream, oVoice, i, text, filesys, newfolder

Const SAFT48kHz16BitStereo = 39
Const SSFMCreateForWrite = 3 'creates the wav file even if it is present in our folder

Set dgeek=CreateObject("sapi.spvoice" )
i=hour(time) 'custom greeting
if i < 12 Then
i=("Good morning, I am Susy, Speech expert created by Daniel the geek" )
dgeek.Speak i
Else
i=("Good day, I am Susy, Speech expert created by Daniel the geek" )
End If

text=msgBox("Welcome - Dann v0.0.1 Text to audio converter" )

msg=InputBox("Enter your text for conversion","Dann v0.0.1 Text to
audio converter" )

If msg = ("F***" ) Then 'word filtering add your preffered words
Err.Clear
Wscript.Echo ("F words are not allowed, this response was trigerred because
you entered an F word into the text field" ) 'display the rules
Else If msg = ("" ) Then 'setting a response if no text has been entered
dgeek.Speak ("You did not type anything for me to say, check back later, since your mind is blank" )
dgeek.WaitUntilDone(1000)
Else
dgeek.Speak msg
End If
End If

'creating a folder to export the sound file to

set filesys=CreateObject("Scripting.FileSystemObject" )
If Not 'checking if the folder does not exist
filesys.FolderExists("c:\Danntextaudio\rec\" ) Then
newfolder = filesys.CreateFolder("c:\Danntextaudio\rec\" ) 'creating a custom folder

Wscript.Echo ("A new folder '" newfolder "' has been created" ) 'alerting user about the new folder
End If

'Saving the text entered as a wav

Set oFileStream = CreateObject("SAPI.SpFileStream" )

oFileStream.Format.Type = SAFT48kHz16BitStereo
oFileStream.Open "C:\Danntextaudio\rec\recording.wav", SSFMCreateForWrite

Set oVoice = CreateObject("SAPI.SpVoice" )
Set oVoice.AudioOutputStream = oFileStream
oVoice.Speak msg
oVoice.WaitUntilDone(10000)

oFileStream.Close

1 Like

(1) (Reply)

Urgent E Comerce Site Programmer Urgently Needed- Design Us A Site To Sell / Computer Engineering Or Computer Science / Why Do Developers Think Jquery Is Obsolete?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 15
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.