How to convert text to speech on Mac using command line utility say

Mac lets you convert text to speech using command line utility “say”. It also lets to generate an audio file in various formats and voices. This is pretty handy to generate audio file given the text. Here are couple of ways to use it:

  1. Use say to pronounce “Hello world” with default voice:
    say "Hello world"
  2. Using say with a pause after Hello:
    say "Hello, world"

    In case you need bigger pause repeat comma e.g.

    say "Hello,, world"
  3. Using say with voice Alex:
    say -v Alex "Hello world"
  4. Using say with voice Alex and output audio to a file (default format aiff):
    say -v Alex "Hello World" -o out.aiff

Sample output for some voices

Here is sample output for text “Using Text to Speech (TTS), you can have Alex and other Mac voices speak selected text so you can hear a word as you see it onscreen.” using various voices:

  1. Using voice Alex (Male Voice):
    say -v Alex "Using Text to Speech (TTS), you can have Alex and other Mac voices speak selected text so you can hear a word as you see it onscreen." -o mac-text-to-speech-tts-demo-alex.aiff

    Outcome: mac-text-to-speech-tts-demo-alex.aiff

  2. Using voice Bruce (Male Voice):
    say -v Alex "Using Text to Speech (TTS), you can have Alex and other Mac voices speak selected text so you can hear a word as you see it onscreen." -o mac-text-to-speech-tts-demo-alex.aiff

    Outcome: mac-text-to-speech-tts-demo-bruce.aiff

  3. Using voice Victoria (Female Voice):
    say -v Alex "Using Text to Speech (TTS), you can have Alex and other Mac voices speak selected text so you can hear a word as you see it onscreen." -o mac-text-to-speech-tts-demo-alex.aiff

    Outcome: mac-text-to-speech-tts-demo-victoria.aiff

Voices available on your system

Voice Alex is one of the most popular voices and you can use it if you don’t want to spend too much time on trying other voices. To see the list of voices available on your system run say -v ?. There are couple of other voices which can be downloaded from Apple’s web site. Here is the default list on Mac OS X 10.7.5 at the time of writing this article.

Agnes
Albert
Alex
Bad News
Bahh
Bells
Boing
Bruce
Bubbles
Cellos
Deranged
Fred
Good News
Hysterical
Junior
Kathy
Pipe Organ
Princess
Ralph
Trinoids
Vicki
Victoria
Whisper

Output formats

The default output format is aiff. To change the output file format, just change the output file extension. To see the list of output file format available run say --file-format=?. Here is the outcome on Max OS X 10.7.5

3gp2 3GPP-2 Audio (.3g2) [Qclp,aac,aace,aach,aacl,aacp]
3gpp 3GP Audio (.3gp) [Qclp,aac,aace,aach,aacl,aacp]
AIFC AIFC (.aifc,.aiff,.aif) [lpcm,ulaw,alaw,ima4,Qclp]
AIFF AIFF (.aiff,.aif) [lpcm]
NeXT NeXT/Sun (.snd,.au) [lpcm,ulaw]
Sd2f Sound Designer II (.sd2) [lpcm]
WAVE WAVE (.wav) [lpcm,ulaw,alaw]
adts AAC ADTS (.aac,.adts) [aac,aach,aacp]
caff CAF (.caf) [Qclp,aac,aace,aach,aacl,aacp,alac,alaw,ilbc,ima4,lpcm,ulaw]
m4af Apple MPEG-4 Audio (.m4a,.m4r) [aac,aace,aach,aacl,aacp,alac]
mp4f MPEG-4 Audio (.mp4) [aac,aace,aach,aacl,aacp]

e.g. To generate a wave format output file run say "Hello World" -o out.wave

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments