Macos speech synthesis

 · 2 min · torgeir

Playing around with ChatGPT text-to-speech in emacs, I discovered that the macos `say` command can do a lot more than I knew about.

Ai Macos Say Speech Synethesis

I have previously used the macos say command for stuff I have to wait for, that I don’t bother watching while I wait, that I want to come back to. Like waiting for when I’m online again.

alias waitforinternet='while true; do ping -c 1 -t 2 nrk.no && say "gotz internet" && date && break; sleep 2; done'

Or If I want to know if a command failed

build || say "ohnoes"

Until I ran man say I had no idea the command could do all this stuff;

  • speak a file with -f
  • adjust the voice with -v
  • adjust the rate with -r
  • write the synthesized audio to a file with -o
  • redirect the spoken audio over the network with -n
  • show progress with --progress

You can list the available voices with say -v '?'

say -v '?' | head -n 4
Albert              en_US    # I have a frog in my throat. No, I mean a real frog!
Alice               it_IT    # Salve, mi chiamo Alice e sono una voce italiana.
Alva                sv_SE    # Hej, jag heter Alva. Jag är en svensk röst.
Amélie              fr_CA    # Bonjour, je m'appelle Amélie. Ma voix est en français canadien.
...

Here’s a bunch of examples

say -v 'alva' hej jag er svensk
say -v 'alva' -r 1.5 hej jag er svensk
say -v 'Samantha' -r 225 hello i\'m Samantha
say -v 'Shelley' -r 225 hello i\'m Samantha
say -v 'Shelley' -r 225 hello i\'m Shelley
say -v 'Sandy' -r 225 hello i\'m Shelley
say -v 'Rocko' -r 225 hello i\'m Shelley
say -v 'Superstar' -r 225 hello i\'m Shelley
say -v 'Organ' -r 225 hello i\'m Shelley
say -v 'Kathy' -r 225 hello i\'m Shelley
say -v 'Karen' -r 225 hello i\'m Karen
say -v 'Jester' -r 225 hello i\'m Karen
say -v 'Grandma' -r 225 hello i\'m Karen
say -v 'Good News' -r 225 hello i\'m Karen
say -v 'Good News' -r 225 hello i\'m Karen
say -v 'Wobble' -r 225 hello i\'m Karen
say -v 'Chellos' -r 225 hello i\'m Karen
say -v 'Bad news' -r 225 hello i\'m Karen

🗣️