Perform text to speech via command line on MacOS

0
16
Perform text to speech via command line on MacOS
Perform text to speech via command line on MacOS

Do you know that you can make your Mac speak? If you are curious how to do it, I will show you how to perform text to speech via command line on MacOS.

The trick here is to use the say command, a little great built-in utility on MacOS that make text-to-speech. Here is how.

To say a given text with default voice:

$ say "It is wonderful to have Mac speak for me"

Make sure to turn on the volume and hear the voice.

You can add a pause with a comma:

$ say "Hello, this is Pete. Nice to meet you"

You can repeat the comma to make it pause longer if you want:

$ say "Hmm,,,, has it paused for too long?"

You can even change the voice, by default, it is Alex voice, let say you want to speak with Samatha (female) voice:

$ say -v Samantha "Hi, this is Samantha. Who am I talking to?"

To can select the voice from this list, which might look different depending on MacOS version.

$ say -v '?'
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.
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
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.
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.
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.
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.

Last but not at least, you can even save the voice output into a recorded file.

$ say -v Samantha "Hi, this is Samantha. Who am I talking to?" -o intro.aiff

Following file formats are supported:

$ say --file-format='?'
3gp2  3GPP-2 Audio         (.3g2) [Qclp,aac,aace,aacf,aacg,aach,aacl,aacp]
3gpp  3GP Audio            (.3gp) [Qclp,aac,aace,aacf,aacg,aach,aacl,aacp]
AIFC  AIFC                 (.aifc,.aiff,.aif) [lpcm,ulaw,alaw,ima4,Qclp]
AIFF  AIFF                 (.aiff,.aif) [lpcm]
BW64  WAVE (BW64 for length over 4 GB) (.wav) [lpcm,ulaw,alaw]
NeXT  NeXT/Sun             (.snd,.au) [lpcm,ulaw,alaw]
RF64  WAVE (RF64 for length over 4 GB) (.wav) [lpcm,ulaw,alaw]
Sd2f  Sound Designer II    (.sd2) [lpcm]
W64f  Wave64               (.w64) [lpcm,ulaw,alaw]
WAVE  WAVE                 (.wav) [lpcm,ulaw,alaw]
adts  AAC ADTS             (.aac,.adts) [aac,aach,aacp]
caff  CAF                  (.caf) [Qclp,aac,aace,aacf,aacg,aach,aacl,aacp,alac,alaw,flac,ilbc,ima4,lpcm,opus,ulaw]
flac  FLAC                 (.flac) [flac]
loas  LATM/LOAS            (.loas,.latm,.xhe) [aac,aace,aacf,aacg,aach,aacl,aacp]
m4af  Apple MPEG-4 Audio   (.m4a,.m4r) [aac,aace,aacf,aacg,aach,aacl,aacp,alac,flac,lpcm]
m4bf  Apple MPEG-4 AudioBooks (.m4b) [aac,aace,aacf,aacg,aach,aacl,aacp]
mp4f  MPEG-4 Audio         (.mp4) [aac,aace,aacf,aacg,aach,aacl,aacp,alac,flac,lpcm]

Alright, that’s it! Now you know how to perform text to speech via command line on MacOS.

Have fun!