How to Make Microsoft Sam Read Notepad Documents?

How to Make Microsoft Sam Read Notepad Documents?
Page content

What is Microsoft Sam?

Microsoft Sam is the useful text to speech tool found in the Windows XP Control Panel under Speech in Classic View and Sounds, Speech and Audio Devices > Speech in Category View.

Most often, it is used as a novelty - type in a few words and listen to the text to speech voice synthesis read out your message.

Beyond this however, Microsoft Sam has more uses and is the main element of Narrator, a screen reading accessibility application that is included with Windows 2000 and XP.

You can try out Narrator by loading it up - go to Start > Programs > Accessories Accessibility.

This screen reader can be used to read many active windows - particularly webpages - however, it isn’t designed to be used with notepad.

Using Microsoft Sam with Visual Basic

Microsoft Narrator settings

Thanks to the VB code made available by this developer however, Microsoft Sam can be used to read .TXT files from Notepad.

There are obvious benefits for this - for instance, Narrator fails to read Word documents successfully and any number of rich text, MS Word format or other document types can be copied into a raw text (.TXT) document, saved and read out by Microsoft Sam.

However, it isn’t possible to use this method to use Microsoft Sam to read out the contents of anything other than English language words and sentences - Microsoft Sam isn’t capable of dealing with the peculiarities of foreign words, structures, punctuation. Similarly, this method also cannot be used to read PHP, JavaScript of other scripting languages.

Saving and Naming the Script

The following script between the “===” should be copied and pasted into a new Notepad document.


‘Script written by Ayman Farhat (SCRIPTmaster)

‘This script allows your PC to read contents of any text file you choose!

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


Set Sapi = Wscript.CreateObject(“SAPI.SpVoice”)

Sapi.speak strText


Save the script, naming it reader.vbs - note the .VBS file extension to denote a Microsoft Visual Basic script.

Using Reader.VBS

Reader.vbs dialogue box

The next step is to create a Notepad file containing the text you wish to be read. As a test, you could use a couple of paragraphs from this guide.

Copy the paragraphs into a new text file in Notepad and save the file - don’t enter a file extension but give the file a memorable name, and ensure it is saved in the same location as reader.vbs.

To have Microsoft Sam read the text file, browse to the location of reader.vbs and run it. A dialogue box will appear, as pictured here - simple enter the name of the text file, without the .TXT extension and click OK. The voice of Microsoft Sam will then be heard as Narrator reads the file from beginning to end!

Check out Notepad Mobile - Polished Wordprocessing and Coding to learn about a raw text editor for Windows Mobile.