Wednesday 6 June 2012

Make your PC speak

Hope this is the right section.
Make you Pc talk without any software.
Copy this and paste in notepad:

Dim msg, sapi
msg=InputBox("Enter your text","Talk it")
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak msg



Then save it as .vbs extension
Run the file and enter whatever text you want.
Tested on Vista 32bits and XP.
For those you want it like a loop:
Copy this and paste in notepad:

 Dim msg, sapi
do
msg=InputBox("Enter your text","Talk it")
Set sapi=CreateObject("sapi.spvoice")
sapi.Speak msg
loop until msg=""



Then save it as .vbs extension
Run the file and enter whatever text you want.
What is does is after the enter text, it would talk then pop back up.
Close by clicking cancel or leaving message blank.
How to make it Read any text file you saved, once it is in the same directory.

Step 1: Copy this and paste in notepad:

Const ForReading = 1
strText = InputBox("Please type in the name of the file you want to read the file, the file has an extension .txt","Read text files from notepad")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objText = objFSO.OpenTextFile(strText + ".txt", ForReading)
strText = objText.ReadAll
objText.Close
Set Sapi = Wscript.CreateObject("SAPI.SpVoice")
Sapi.speak strText



Step 2: Then save it as whatever you want.vbs extension
Step 3: Open notepad write whatever you want there and save it with the default extension which is usually .txt
Step 4: Now make sure the text file is in the same directory as the .vbs you save.
Step 5: Run the .vbs and enter the name of the text file, caps does not matter

No comments:

Post a Comment