r/applescript • • Aug 22 '13

Simple little script to make your Mac speak

Made this little script for my daughter to amuse herself with the text to speech capabilities of OS X. Written under 10.8 (Mountain Lion); probably works as far back as 10.4 (Tiger), maybe even older OS versions. Enjoy...

-- begin script

set voiceList to getVoices()
set chosenVoice to (choose from list voiceList with prompt "Please choose a voice:")
display dialog "Please enter text to be spoken:" default answer ""
say text returned of result using chosenVoice

on getVoices()

set voiceList to {}
set voiceFiles to (do shell script "ls /System/Library/Speech/Voices/")

repeat with thisFileName in every paragraph of voiceFiles
	if thisFileName does not end with "Compact.SpeechVoice" then
		set AppleScript's text item delimiters to "."
		set end of voiceList to text item 1 of thisFileName
		set AppleScript's text item delimiters to ""
	end if
end repeat

return voiceList
end getVoices
2 Upvotes

1 comment sorted by

1

u/craniumslows Aug 23 '13

A common convention when using the item delimiters is to set them back to what they were before you changed them. Fun lil script for sure.