Make your Computer Talk
To create a VBS script, follow the steps given below:-
➤ Go to 'Start' then search for "Notepad" and open it.
➤ Copy and Paste one of the code given below into the Notepad.
Below are some VBS script or code that will make your Computer Talk.
1. Input text to speak message
Dim Message, Speak
Message=InputBox("|Abe| Enter Text you want me to say","Speak")
Set Speak=CreateObject("sapi.spvoice")
Speak.Speak Message
Message=InputBox("|Abe| Enter Text you want me to say","Speak")
Set Speak=CreateObject("sapi.spvoice")
Speak.Speak Message
➤ Now click on 'File Menu', then click on 'Save' (If it is already a saved file then click on 'Save As'), select 'All Types' in Save as Type option, and save the file as 'Speak.vbs' or any name you want with ".vbs" extension.
If you want your computer to speak again and again (or loop) the text you typed then use the below code.
Dim Message, Speak
Message=InputBox("|Abe| Enter Text you want me to say","Speak")
Set Speak=CreateObject("sapi.spvoice")
do
Speak.Speak Message
loop
Message=InputBox("|Abe| Enter Text you want me to say","Speak")
Set Speak=CreateObject("sapi.spvoice")
do
Speak.Speak Message
loop
If you want your computer to speak on opening the .vbs file, means without entering the text in the Box, then use the below code in which you can put your text in the code which you want to hear.
dim speechobject
set speechobject=createobject("sapi.spvoice")
speechobject.speak "hello my friend welcome to abezworld"
set speechobject=createobject("sapi.spvoice")
speechobject.speak "hello my friend welcome to abezworld"
➤ Now replace texts denoted in red in the above code with whatever you want to hear.
If you want to loop the text you entered with the above then use the below code.
dim speechobject
set speechobject=createobject("sapi.spvoice")
do
speechobject.speak "hello my friend welcome to abezworld"
loop
set speechobject=createobject("sapi.spvoice")
do
speechobject.speak "hello my friend welcome to abezworld"
loop
➤ Replace texts denoted in red in the above code with whatever you want to hear.
To Disable the .vbs Script, follow the below step
➤ Open Task Manager in your computer (you can use shortcut "Ctrl + Shift + Esc" on your Keyboard to open Windows Task Manager). Now locate "wscript.exe" and select it, and click on "End Process".
2. Greeting
By using Greeting VBScript Script your computer will greet you in a certain way based on the time on your computer. Copy paste the below code into notepad, and save it with .vbs extension. You can replace the texts denoted in red in the below code with the text you want to hear.
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
dim str
if hour(time) < 12 then
Sapi.speak "Good Morning my Friend"
else
if hour(time) < 16 then
Sapi.speak "Good afternoon my Friend"
else
if hour(time) > 16 then
Sapi.speak "Good evening my Freind"
else
Sapi.speak "Good afternoon my Friend"
end if
end if
end if
dim str
if hour(time) < 12 then
Sapi.speak "Good Morning my Friend"
else
if hour(time) < 16 then
Sapi.speak "Good afternoon my Friend"
else
if hour(time) > 16 then
Sapi.speak "Good evening my Freind"
else
Sapi.speak "Good afternoon my Friend"
end if
end if
end if
After creating the .vbs file double-click on it, now your computer will greet you, based on the time that your computer shows. Your computer will speak the text that you have provided, which are denoted in red in the above code.
3. Time of the Day
If you want your Computer to speak out the current time, then use the below code for that. Your computer will speak out the time that is set on your computer. Copy paste the below code into notepad, and save it with .vbs extension. You can replace the texts denoted in red in the below code with whatever you want to hear.
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
Sapi.speak "Hi current time is"
if hour(time) > 12 then
Sapi.speak hour(time)-12
else
if hour(time) = 0 then
Sapi.speak "12"
else
Sapi.speak hour(time)
end if
end if
if minute(time) < 10 then
Sapi.speak "o"
if minute(time) < 1 then
Sapi.speak "clock"
else
Sapi.speak minute(time)
end if
else
Sapi.speak minute(time)
end if
if hour(time) > 12 then
Sapi.speak "P.M."
else
if hour(time) = 0 then
if minute(time) = 0 then
Sapi.speak "Midnight"
else
Sapi.speak "A.M."
end if
else
if hour(time) = 12 then
if minute(time) = 0 then
Sapi.speak "Noon"
else
Sapi.speak "P.M."
end if
else
Sapi.speak "A.M."
end if
end if
end if
Sapi.speak "Hi current time is"
if hour(time) > 12 then
Sapi.speak hour(time)-12
else
if hour(time) = 0 then
Sapi.speak "12"
else
Sapi.speak hour(time)
end if
end if
if minute(time) < 10 then
Sapi.speak "o"
if minute(time) < 1 then
Sapi.speak "clock"
else
Sapi.speak minute(time)
end if
else
Sapi.speak minute(time)
end if
if hour(time) > 12 then
Sapi.speak "P.M."
else
if hour(time) = 0 then
if minute(time) = 0 then
Sapi.speak "Midnight"
else
Sapi.speak "A.M."
end if
else
if hour(time) = 12 then
if minute(time) = 0 then
Sapi.speak "Noon"
else
Sapi.speak "P.M."
end if
else
Sapi.speak "A.M."
end if
end if
end if
Double-click the file you created and your computer will say the current time of the day.
4. Greeting + Time of the day
If we combine the above two codes then your computer will greet you and will also tell you the current time. So, if you want your computer to greet you and also tell the current time, then, use the below code. Copy paste the code that is provided below into notepad, and save it with .vbs extension. You can replace the texts denoted in red in the below code with whatever you want.
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
dim str
if hour(time) < 12 then
Sapi.speak "Good Morning my Friend"
else
if hour(time) < 16 then
Sapi.speak "Good afternoon my Friend"
else
if hour(time) > 16 then
Sapi.speak "Good evening my Freind"
else
Sapi.speak "Good afternoon my Friend"
end if
end if
end if
Sapi.speak "Current time is"
if hour(time) > 12 then
Sapi.speak hour(time)-12
else
if hour(time) = 0 then
Sapi.speak "12"
else
Sapi.speak hour(time)
end if
end if
if minute(time) < 10 then
Sapi.speak "o"
if minute(time) < 1 then
Sapi.speak "clock"
else
Sapi.speak minute(time)
end if
else
Sapi.speak minute(time)
end if
if hour(time) > 12 then
Sapi.speak "P.M."
else
if hour(time) = 0 then
if minute(time) = 0 then
Sapi.speak "Midnight"
else
Sapi.speak "A.M."
end if
else
if hour(time) = 12 then
if minute(time) = 0 then
Sapi.speak "Noon"
else
Sapi.speak "P.M."
end if
else
Sapi.speak "A.M."
end if
end if
end if
dim str
if hour(time) < 12 then
Sapi.speak "Good Morning my Friend"
else
if hour(time) < 16 then
Sapi.speak "Good afternoon my Friend"
else
if hour(time) > 16 then
Sapi.speak "Good evening my Freind"
else
Sapi.speak "Good afternoon my Friend"
end if
end if
end if
Sapi.speak "Current time is"
if hour(time) > 12 then
Sapi.speak hour(time)-12
else
if hour(time) = 0 then
Sapi.speak "12"
else
Sapi.speak hour(time)
end if
end if
if minute(time) < 10 then
Sapi.speak "o"
if minute(time) < 1 then
Sapi.speak "clock"
else
Sapi.speak minute(time)
end if
else
Sapi.speak minute(time)
end if
if hour(time) > 12 then
Sapi.speak "P.M."
else
if hour(time) = 0 then
if minute(time) = 0 then
Sapi.speak "Midnight"
else
Sapi.speak "A.M."
end if
else
if hour(time) = 12 then
if minute(time) = 0 then
Sapi.speak "Noon"
else
Sapi.speak "P.M."
end if
else
Sapi.speak "A.M."
end if
end if
end if
Double-click the file you have created by using the above code, and your computer will greet you and will tell you the current time.
If you want your computer to greet you every time you turn it ON then go to ➜ Make your Computer Welcome you with a voice message on startup
1 Comments
Nice
ReplyDelete