MacOS OSX How to change the text to speech voice in terminal or with a keyboard shortcut?

Viewed 1468

I'm looking for a way to change the voice with a shortcut: going in to settings->accessibility->Speech and setting the voice "Alex" take's to long.

Does anyone know a terminal command? Or a way to change it with a keyboard shortcut?

I use speech in English and in Dutch so i have to manually change the voice a couple of times a day. thx

2 Answers

Thanks @cello for the tip: https://github.com/mklement0/voices

I created a small appleScript to change the voice

on run {}
    set changeVoiceToo to ""
    set currentVoice to do shell script "export PATH=/usr/local/bin:$PATH;" & "voices -b"

    if currentVoice is "Alex" then
        set changeVoiceToo to "Xander"
    else
        set changeVoiceToo to "Alex"
    end if

    do shell script "export PATH=/usr/local/bin:$PATH; voices -d " & changeVoiceToo

    do shell script "export PATH=/usr/local/bin:$PATH; say " & changeVoiceToo
    # display notification currentVoice sound name "Tink"
    display notification "Voice Change!" with title changeVoiceToo # sound name "Tink"
end run

I hope this is useful to somebody

Related