以编程方式获取Mac文本到语音的列表?

Mar*_*son 28 macos text-to-speech

mac命令say可以指定与-v标志一起使用的语音.

say -v Alex "compile completed, put your swords down."
Run Code Online (Sandbox Code Playgroud)

可在系统偏好设置/语音/文本到语音中看到可用的声音.如何以编程方式获取此列表?

Igo*_*ych 91

这是可用语音列表:

say -v '?'
Run Code Online (Sandbox Code Playgroud)


nro*_*ose 25

for voice in `say -v '?' | awk '{print $1}'`; do say -v "$voice" "Hello, my name is $voice."; done
Run Code Online (Sandbox Code Playgroud)


Mar*_*son 11

Python版本,由Barry Wark提供:

from AppKit import NSSpeechSynthesizer
print NSSpeechSynthesizer.availableVoices()
Run Code Online (Sandbox Code Playgroud)


Mar*_*son 8

外壳版,没有黑客太便宜了!

(实际上不要使用它,而是使用python版本.)

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

Agnes
Albert
Alex
BadNews
Bahh
Bells
Boing
...
Run Code Online (Sandbox Code Playgroud)