Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A script to convert text to a spoken AIFF file System
Here is a (free) way to save spoken text in an AIFF file. Paste the following AppleScript into Script Editor and save as an application:
say (text returned of (display dialog ¬
"Enter what you would like synthesized into a file." default answer ¬
"Welcome to Mac OS X.")) saving to (choose file name with prompt ¬
"Choose where you would like to to save the file." default name "say.aiff")
It will first ask you what you want synthesized and then where you would like to save the file to. Note that a generated five minute synthesized file will not need to take five minues to save. It will not play the spoken text, and instead just build the spoken text into the saved file instantly.

[Editor's note: I tested this script and it works as expected ... but if you've got iTunes set to add things to the library automatically, don't forget that it happily adds AIFF files as well as MP3s ... not that I'd ever do anything like that!]
    •    
  • Currently 0.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (0 votes cast)
 
[10,981 views]  

A script to convert text to a spoken AIFF file | 9 comments | Create New Account
Click here to return to the 'A script to convert text to a spoken AIFF file' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Speak a text file to AIFF
Authored by: Eravau on Dec 19, '02 12:05:50PM
If you'd like to synthesize a lot of text (more than a small phrase in a dialog box), you can type it into a text file in your favorite text editor. Then you can run the following script:


set file_to_read to (choose file with prompt "What should I read?")
open for access file_to_read
set speak_me to read file_to_read
say speak_me saving to (choose file name with prompt ¬
"Save sound file..." default name "speak_me.aiff")


When it asks what file to read, jut choose the text file into which you typed your text. Or if you wanted, you could save a web page from your web browser as text (not as source) and have it read that file to you.



[ Reply to This | # ]
Speak a text file to AIFF
Authored by: Eravau on Dec 19, '02 05:12:28PM
Actually, it looks like I figured that out for nothing...


If you looke at one of Apple's AppleScript pages it has a couple of nice scripts with even more extensive abilities than the hint or mine.


One thing I would like to add, though... If you want a web page automatically saved to a text file (via AppleScript) for processing with one of these scripts, the best alternative I've found is using a do shell script command and running links (text-based web browser) with the -dump flag. For example:


do shell script "/sw/bin/links
-dump http://www.macosxhints.com/
> ~/Desktop/MacOSXHints"


(Note: the 3 bold lines above should be one line, but are broken for readability. Just rejoin them with a space at the end of each line above. This requires that you have the links web browser installed...which you can do with fink.)


...will dump a text-rendered version of the front page of this web site to a file on your desktop. You could then open the file manually with the script above...or just add it to the script and have it automatically go through all of the pages you want turned into audio files and download, open, and speak to file for each one.


You could probably even AppleScript iTunes to encode it to mp3 for you and sync it to your iPod so that you can have your favorite web pages read to you on the go. According to iTune's AppleScript dictionary, there are convert and update commands to do just these things.


Since I don't have an iPod, I didn't have enough motivation to work out all the syntax and write the script, but if somebody wants to give me an iPod for Christmas, I think I could work up enough energy to do that. = )


[ Reply to This | # ]

Speak a text file to AIFF
Authored by: hayne on Jan 03, '03 03:22:21AM

Here's a Bourne shell version (which is perhaps more convenient for use from the Terminal):

#!/bin/sh

# This script uses text-to-speech to convert the text in an ASCII text file
# to an audible form and saves it in an audio file.
# This script expects two command-line arguments:
# The first argument is the name of a text file
# The second argument is the name to use when saving the audio
# (the audiofile name should usually have a ".aiff" suffix)

message=`cat $1`
audiofile=$2

echo "set ofile to POSIX file \\"$audiofile\\"
say \\"$message\\" saving to ofile" | /usr/bin/osascript



[ Reply to This | # ]
backslash screw-up
Authored by: hayne on Jan 03, '03 03:26:08AM

Those double backslashes should be single backslashes.
(Geeklog's preview misled me)
The backslashes are for escaping the double quotes.



[ Reply to This | # ]
Script Editor?
Authored by: ylon on Dec 19, '02 12:48:22PM

You'll have to forgive me, I'm rather new to MacOS X. Where do we find the Script Editor app? (I'm used to emacs :)



[ Reply to This | # ]
Script Editor?
Authored by: sreeves on Dec 19, '02 01:51:38PM

Script Editor is in the "/Applications/AppleScript" folder.

Apple has provided some scripts that convert text to sound files at "http://www.apple.com/applescript/macosx/text2audio.html".



[ Reply to This | # ]
Script Editor?
Authored by: alset on Jan 01, '03 12:05:50AM

I hope it hasn't been so much time that you aren't following this thread anymore. The Script Editor is in the AppleScript folder. /Applications/AppleScript/Script Editor.

Hope this helps.
Dan



[ Reply to This | # ]
iSpeak It
Authored by: Werd on Dec 19, '02 07:09:30PM

For a much easier, more complete solution, try iSpeak It. Very Cool. It does everything you guys are asking for...

http://www.ispeak-it.com/



[ Reply to This | # ]
No!
Authored by: dave1212 on Jan 10, '03 06:37:30PM

No! We want to learn AppleScript!



[ Reply to This | # ]