Getting list of Mac text-to-speech voices programmatically?
Asked Answered
S

8

32

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?

Silique answered 28/9, 2009 at 23:6 Comment(0)
C
6

[NSSpeechSynthesizer availableVoices]

Crocker answered 28/9, 2009 at 23:20 Comment(3)
nice! This wouldn't be callable via python by any chance?Silique
I'm sure you could call it through PyObjC, which is included with Mac OS X 10.5 and above (and downloadable for earlier versions).Crocker
you're right, I've copied the incanation below... thanks a bunch!!Silique
M
103

This is the list of available voices:

say -v '?'
Midden answered 21/2, 2013 at 10:56 Comment(1)
Not on 10.6. (SO 15 char filler text)Bascom
I
26
for voice in `say -v '?' | awk '{print $1}'`; do say -v "$voice" "Hello, my name is $voice."; done
Ishmael answered 7/5, 2015 at 14:17 Comment(0)
S
11

Python Version, courtesy of Barry Wark:

from AppKit import NSSpeechSynthesizer
print NSSpeechSynthesizer.availableVoices()
Silique answered 29/9, 2009 at 4:47 Comment(0)
S
7

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
...
Silique answered 29/9, 2009 at 0:26 Comment(0)
C
6

[NSSpeechSynthesizer availableVoices]

Crocker answered 28/9, 2009 at 23:20 Comment(3)
nice! This wouldn't be callable via python by any chance?Silique
I'm sure you could call it through PyObjC, which is included with Mac OS X 10.5 and above (and downloadable for earlier versions).Crocker
you're right, I've copied the incanation below... thanks a bunch!!Silique
A
2

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.

Anthology answered 27/11, 2014 at 22:52 Comment(0)
S
2

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
Solitude answered 19/2, 2020 at 11:41 Comment(0)
Z
0
for i in `say --voice=? | cut -f 1 -d' ' ` ; do  
  echo $i;  say --voice=$i $i
done
Zarf answered 21/10, 2020 at 10:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.