₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,143 members, 8,420,533 topics. Date: Thursday, 04 June 2026 at 11:51 PM

Toggle theme

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

Nairaland ForumScience/TechnologyProgrammingSimple Text-To-Speech Program using Vbscript. Do It Yourself. (1802 Views)

1 Reply

Simple Text-To-Speech Program using Vbscript. Do It Yourself. by Nobody:
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:
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 Reply

Text To Voice Call Adverts At Www.text2voiceads.com/call @60 NairaHow To Create A Text To Speech Software With NotepadJoomla: How To Link A Text To A Definite Joomla Category234

I Need A Competent Website BuilderPython Programmers' LoungeCCNA Self-training