Technical notes index

HOW TO TURN A TEXT FILE INTO A SPEECH RECORDING IN MAC OSX


If you want a text document to be converted to an audio file to listen to on your iPod or whatever, then this Applescript will achieve this. I have provided a copy of this as an application here:  DOWNLOAD.

To use:

1. Run the script, select a plain text file in the dialog.

2. Enter a voice to use, or just click "OK" to use the default voice selected in System Preferences.

3. Enter a name for the sound file which will be created.

If the text is a long one it may take some time to complete (wait for the application to close). Note that the original must be a plain text file: if you open a file made in a word processing program it will read all the coded garbage.

The file will be saved in AIFF format to the Desktop. You can convert it to MP3 if required in iTunes.

If you prefer you can make up the application yourself. Copy the following into the AppleScript Editor:
____________________________________________

property xyz : ""
property fname : ""
property pth : ""
property vce : ""
property snme : ""

set fname to choose file with prompt "Choose a Plain Text file to read"

set pth to fname as string

set user_input to display dialog "Choose a voice, or just click OK to use the default voice" default answer "" buttons {"Cancel", "OK"} default button "OK" with icon note
if button returned of user_input is "OK" then
set vce to text returned of user_input as string
end if

set user_input to display dialog "Enter a name for the sound file" default answer "" buttons {"Cancel", "OK"} default button "OK" with icon note
if button returned of user_input is "OK" then
set snme to text returned of user_input as string
end if

set xyz to read file pth

say xyz using vce saving to ((path to desktop as text) & snme & ".aiff") 

_____________________________________________________

Save as an application.


There are some additional voices for sale at http://cepstral.com/ , of which 'David' is probably the most realistic.

© Roger Wilmut