30
votes

The mac command say can specify the voice used with the -v flag.

say -v Alex "compile completed, put your swords down."

The available voices can be seen in System Preferences/Speech/Text to Speech. How can I get this list programmatically?

8

8 Answers

97
votes

This is the list of available voices:

say -v '?'
25
votes
for voice in `say -v '?' | awk '{print $1}'`; do say -v "$voice" "Hello, my name is $voice."; done
11
votes

Python Version, courtesy of Barry Wark:

from AppKit import NSSpeechSynthesizer
print NSSpeechSynthesizer.availableVoices()
8
votes

Shell Version, no hack too cheap!

(Don't actually use this, use the python version instead.)

ls /System/Library/Speech/Voices | sed 's/.SpeechVoice$//'

Agnes
Albert
Alex
BadNews
Bahh
Bells
Boing
...
2
votes

It is worth going through several of the voices before deciding on one. There is a huge variation in quality.

For example, Tom sounds a bit impatient, but way more realistic than Alex. And some of the British voices are great.

Using say -v '?' gives you a list of the installed voices plus some sample sentences that give you an idea what to expect of the voice. You have to go through preferences to install most of the really good voices, but they come with a Compact voice file that lets you hear what each voice sounds like before you actually download them.

2
votes

You can use the following to sample all the available voices:

say -v '?' | awk '{$2=$3=""; printf "-v %s", $1; $1=""; print " \"" $0 "\""}'| xargs -L1 say
0
votes
for i in `say --voice=? | cut -f 1 -d' ' ` ; do  
  echo $i;  say --voice=$i $i
done