Text-to-speech in macOS : having fun with say command to make your macOS talk to you

Maith Egeek
8 min readMay 19, 2021

MacOS have a fun command-line program called “say”: you type “say” and enter some text and it reads to you. It also has a text-to-speech functionality : you highlight any text and it reads to you.

This is a quick tutorial how to use the text-to-speech in macOS : to read any text in any program, to use the terminal with the say command to speak to you, and the different parameters to change the voices, languages and parameters (pitch, speed …). With all these different options, you can really have fun and generate audio files for professional purpose or for pranks :)

NB : These have been tested on my macOS Big Sur 11.3.1 with the Apple M1 chip.

Make your mac read any text : Spoken Content

You can tell your mac to convert any text to speech. As a pre-installed text-to-speech system, you can use this functionality to provide feedback to users during script execution; instead of reading a message visually, the user can listen to it audibly.

Enable speak selection in the Accessibility menu

To have macos read out loud any written text, you first need to enable it in System Preferences > Accessibility. In the left pane, select Spoken Content. And select Speak selection. Click on Options and choose the Keyboard shortcut you prefer.

Choose the shortcut and options of the Speak selection

Then, to use Speak selection, just select any text in a document (text, doc, in your browser, in a pdf … ) and use your shortcut. It should read your text out loud and display a pop up menu where you can pause, stop, control the speed … (if you can not hear, please check that you have not muted your speakers)

Control ofthe Speak selection

Your Mac can Say Hello to You : Basics

Now, you can also have more fun with the terminal commands. The magical “say” command in your macos terminal is really unique. This is the simple example of the say command:

say “hello”

will output a voice that has been set by default in your system preferences. The only restriction with this is that the text-to-voice interpreter is only in English. But you can even save the output as a aiff file:

say “hello world” -o hello.aiff

Since macos x 10.6, you can also change the file format:

say “hello world” -o hello — file-format m4af
say “hello world” -o hello.m4a

Both the above commands output the file hello.m4a. Available output formats are AIFF, caff, m4af, WAVE.

Unfortunately, outputting a mp3 file is not yet possible directly. Still, you can simply convert the output file into a mp3 with the lame command say “text to read out loud” -o filename.extension : for instance :

say “hello world” -o hello.aifflame -m m hello.aiff hello.mp3

You can change the speed/speech rate with option -r Nor the embedded speech command [[rate N]], where N is the nimber of words per minutes:

say -r 400 "Just what do you think you're doing Dave?"
say "[[rate 400]] Just what do you think you're doing Dave?"

You can even choose your voice and have much more fun with the command :

say -v “voiceName” “text to say”

For instance, with Daniel’s voice:

say -v Daniel “i am a lady”

You have in English UK language the pre-installed voices in MacOS 11.3 Big Sur of :

  • Daniel
  • Kate
  • Serena
  • Siri voice 1
  • Siri voice 2

In the English US language, you have much more options :

  • Agnes
  • Alex
  • Allison
  • Ava
  • Bruce
  • Fred
  • Junior
  • Kathy
  • Nicky
  • Princess
  • Ralph
  • Siri voice 1
  • Siri voice 2
  • Siri voice 3
  • Siri voice 4
  • Susan
  • Tom
  • Vicky
  • Victoria
  • Albert
  • Bad News
  • Bahh
  • Bells
  • Boing
  • Bubbles
  • Cellos
  • Deranged
  • Good News
  • Hysterical
  • Pipe Organ
  • Trinoids
  • Whisper
  • Zarvox

In French France, you have 5 voices:

  • Audrey
  • Aurelie
  • Siri Voice 1
  • Siri Voice 2
  • Thomas

If this parameter -v is unspecified, the default is the voice selected in System Preferences.

Display the pre-installed voices in System Preferences

You can easily check the available voices and install new voices in System Preferences > Accessibility. In the left pane, select Spoken content. From the System Voice drop-down menu, you can see the list of already installed voices. You can change here the default voice. Select Customise to add more voices and more languages. You can pre-hear these voices by clicking on the voice name and then clicking the Play button. Once you select new voices, click on OK and they will be downloaded. It might take a few minutes.

Install more voices and languages in the Accessibility menu

More examples on http://www.usingmac.com/2008/6/24/terminal-sings-songs

However, not all these voices are available with the say command. To get the list of voices available, use one of these terminal commands :

say -v’?’
say --voice="?"

For me, it displays :

Alex en_US # Most people recognize me by my voice.
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.
Amelie fr_CA # Bonjour, je m'appelle Amelie. Je suis une voix canadienne.
Anna de_DE # Hallo, ich heiße Anna und ich bin eine deutsche Stimme.
Audrey fr_FR # Bonjour, je m'appelle Audrey. Je suis une voix française.
Aurelie fr_FR # Bonjour, je m'appelle Aurelie. Je suis une voix française.
Carmit he_IL # שלום. קוראים לי כרמית, ואני קול בשפה העברית.
Damayanti id_ID # Halo, nama saya Damayanti. Saya berbahasa Indonesia.
Daniel en_GB # Hello, my name is Daniel. I am a British-English voice.
Diego es_AR # Hola, me llamo Diego y soy una voz española.
Ellen nl_BE # Hallo, mijn naam is Ellen. Ik ben een Belgische stem.
Fiona en-scotland # Hello, my name is Fiona. I am a Scottish-English voice.
Fred en_US # I sure like being inside this fancy computer
Good News Compact en_US # Congratulations you just won the sweepstakes and you don't have to pay income tax again.
Ioana ro_RO # Bună, mă cheamă Ioana . Sunt o voce românească.
Joana pt_PT # Olá, chamo-me Joana e dou voz ao português falado em Portugal.
Jorge es_ES # Hola, me llamo Jorge y soy una voz española.
Juan es_MX # Hola, me llamo Juan y soy una voz mexicana.
Kanya th_TH # สวัสดีค่ะ ดิฉันชื่อKanya
Karen en_AU # Hello, my name is Karen. I am an Australian-English voice.
Kate en_GB # Hello, my name is Kate. I am a British-English voice.
Kyoko ja_JP # こんにちは、私の名前はKyokoです。日本語の音声をお届けします。
Laura sk_SK # Ahoj. Volám sa Laura . Som hlas v slovenskom jazyku.
Lekha hi_IN # नमस्कार, मेरा नाम लेखा है. मैं हिन्दी में बोलने वाली आवाज़ हूँ.
Luca it_IT # Salve, mi chiamo Luca e sono una voce italiana.
Luciana pt_BR # Olá, o meu nome é Luciana e a minha voz corresponde ao português que é falado no Brasil
Maged ar_SA # مرحبًا اسمي Maged. أنا عربي من السعودية.
Mariska hu_HU # Üdvözlöm! Mariska vagyok. Én vagyok a magyar hang.
Mei-Jia zh_TW # 您好,我叫美佳。我說國語。
Melina el_GR # Γεια σας, ονομάζομαι Melina. Είμαι μια ελληνική φωνή.
Milena ru_RU # Здравствуйте, меня зовут Milena. Я - русский голос системы.
Moira en_IE # Hello, my name is Moira. I am an Irish-English voice.
Monica es_ES # Hola, me llamo Monica y soy una voz española.
Nora nb_NO # Hei, jeg heter Nora. Jeg er en norsk stemme.
Oliver en_GB # Hello, my name is Oliver. I am a British-English voice.
Paulina es_MX # Hola, me llamo Paulina y soy una voz mexicana.
Rishi en_IN # Hello, my name is Rishi. I am an Indian-English voice.
Samantha en_US # Hello, my name is Samantha. I am an American-English voice.
Sara da_DK # Hej, jeg hedder Sara. Jeg er en dansk stemme.
Satu fi_FI # Hei, minun nimeni on Satu. Olen suomalainen ääni.
Serena en_GB # Hello, my name is Serena. I am a British-English voice.
Sin-ji zh_HK # 您好,我叫 Sin-ji。我講廣東話。
Tessa en_ZA # Hello, my name is Tessa. I am a South African-English voice.
Thomas fr_FR # Bonjour, je m'appelle Thomas. Je suis une voix française.
Ting-Ting zh_CN # 您好,我叫Ting-Ting。我讲中文普通话。
Veena en_IN # Hello, my name is Veena. I am an Indian-English voice.
Victoria en_US # Isn't it nice to have a computer that will talk to you?
Xander nl_NL # Hallo, mijn naam is Xander. Ik ben een Nederlandse stem.
Yelda tr_TR # Merhaba, benim adım Yelda. Ben Türkçe bir sesim.
Yuna ko_KR # 안녕하세요. 제 이름은 Yuna입니다. 저는 한국어 음성입니다.
Yuri ru_RU # Здравствуйте, меня зовут Yuri. Я - русский голос системы.
Zosia pl_PL # Witaj. Mam na imię Zosia, jestem głosem kobiecym dla języka polskiego.
Zuzana cs_CZ # Dobrý den, jmenuji se Zuzana. Jsem český hlas.

For instance, after installing the voice Good News, the list of voices displayed by say -v’?’ should have a new line:

Good News Compact en_US # Congratulations you just won the sweepstakes and you don’t have to pay income tax again.

I can use either commands

say -v Good “i am a geek”say -v “Good News” “i am a geek”

Unfortunately the voice Siri does not work.

say -v Siri “i am a geek”

Voice `Siri’ not found.

say -v “Siri Voice 1” “i am a geek”

Voice `Siri Voice 1' not found.

Using an script file

You can also use a file as an input. If your script is a file script.txt, simply use the command

say -f script.txt
say -v Daniel -f script.txt -o ouput.aiff

Modulating the speech with effect tags

You can add a lot of effects with tags:

  • [[ slnc 5000 ]] : silence for 5s.
  • [[volm 0.9]] changes the volume to the indicated level.
  • [[volm +0.1]] increases the volume by the indicated level.
  • [[rate 150]] changes the speed
  • [[pbas 50]] changes the pitch.
  • [[ rset ]] resets all these parameters to default
  • ‘word’ :quotes also put the emphasis on the word.

Below is an example of a script I used:

[[ slnc 5000 ]]
[[rate 150]][[volm 0.9]]
I am going to present studies about how we can [[rate 130]] build a ‘curious’ robot learner for ‘interactive goal-babbling’ [[rate 150]] by designing a system [[rate 130]]for [[volm 1.1]]strategically[[volm 0.9]] choosing, ‘what’, ‘how’, ‘when’, and from ‘whom’ to learn[[rate 150]]. In other words, the system [[volm 1]]chooses[[volm 0.9]] [[rate 140]]the ‘content’, ‘procedure’, ‘timing’ and ‘source’ of its learning process.[[rate 150]]
[[ slnc 1300 ]]

The complete list of commands and how to use them can be found https://developer.apple.com/library/mac/documentation/userexperience/conceptual/SpeechSynthesisProgrammingGuide/FineTuning/FineTuning.html.

You can also try applescripts (with Script Editor) and javascript. See https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/SpeakText.html for more details.

--

--