Mark Harrison
Mark Harrison

Reputation: 304624

Getting list of Mac text-to-speech voices programmatically?

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?

Upvotes: 33

Views: 19408

Answers (8)

O Wigley
O Wigley

Reputation: 237

for i in `say --voice=? | cut -f 1 -d' ' ` ; do  
  echo $i;  say --voice=$i $i
done

Upvotes: 0

Luis Davim
Luis Davim

Reputation: 111

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

Upvotes: 2

Chuck
Chuck

Reputation: 237100

[NSSpeechSynthesizer availableVoices]

Upvotes: 6

nroose
nroose

Reputation: 1812

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

Upvotes: 26

Karsten Johansson
Karsten Johansson

Reputation: 21

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.

Upvotes: 2

Igor Shubovych
Igor Shubovych

Reputation: 2820

This is the list of available voices:

say -v '?'

Upvotes: 105

Mark Harrison
Mark Harrison

Reputation: 304624

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
...

Upvotes: 7

Mark Harrison
Mark Harrison

Reputation: 304624

Python Version, courtesy of Barry Wark:

from AppKit import NSSpeechSynthesizer
print NSSpeechSynthesizer.availableVoices()

Upvotes: 11

Related Questions