March 29, 2017

Say Terminal Command

Unix Header

The Terminal 'Say" command is a utility that converts text to audible speech. This is the same speech technology that MacOS uses when you select a text and ask to speak.

With this command and some voice files, you can create some unique audio clips. The MacOS comes with over 48 speech files.

Simple Execution

To run the command, you tell "Say" the voice you want to use and then what text to speak:

Say -v Bruce "Hello World"

Instead of entering a text at the command line, you could reference a text file by using the "-f" command.

Say -v Bruce speech.txt

If you which to output the speech to a file use the "-o" and the name of the file. If you don't include a file extension, the file format will be AIFF which is basically no audio compression - and you end up with a very large sound file. The best format to use, at least in my testing, is m4p.

Say -v Bruce "Hello World" -o hello.m4p

Bash Script Example

You can sample all the audio clips by using this simple Bash script:

#! /bin/bash
array=("Agnes" "Albert" "Alex" "Alice" "Alva" "Amelie" "Anna" "Bad News" "Bahh" "Bells" "Boing" "Bruce" "Bubbles" "Carmit" "Cellos" "Damayanti" "Daniel" "Deranged" "Diego" "Ellen" "Fiona" "Fred" "Good News" "Hysterical" "Ioana" "Joana" "Jorge" "Juan" "Junior" "Kanya" "Karen" "Kathy" "Katya" "Kyoko" "Laura" "Lekha" "Luca" "Luciana" "Maged" "Mariska" "Mei-Jia" "Melina" "Milena" "Moira" "Monica" "Nora" "Paulina" "Pipe Organ" "Princess" "Ralph" "Samantha" "Sara" "Satu" "Sin-ji" "Tessa" "Thomas" "Ting-Ting" "Trinoids" "Veena" "Vicki" "Victoria" "Whisper" "Xander" "Yelda" "Yuna" "Yuri" "Zarvox" "Zosia" "Zuzana")

for i in "${array[@]}"
do
   say -v $i -f stock.txt -o $i.m4p
done

What this file does

This Bash script will loop through each speech file and output the speech to an M4p file. You can then listen to each clip and find the perfect audio for your needs.

There is an individual file for each sound so you know the name of the voice that you are listening to.

Just make sure to put this script in a place where all the audio files are going. The folder size will be 279 MB.

Halloween Scary Fun

Some Macintosh users find the Whisper voice to be creepy. Whisper doesn't come by default. You will need to install it. Simple Install Instructions

  • Go to the System Preferences
  • Select Accessibility
  • Look for the Speech icon
  • Next to System Voice, select the pull down and select Customize
  • Under the 'English (United States) - Novelty' select Whisper
  • Click 'OK'
  • Note: Downloading the Whisper will also update the Samantha and Alex voices to higher quality.
Once you have it installed, Try this example:
say -v Whisper "We are watching you"

More Voices Available

If your really into Text-To-Speech, check out the collection of voices at CereProc. They have a rather large collection of voices in various accents and languages.

The voices cost ~ $30, however right now they have a sale for 50% for personal use. The voices are really cool and very natural sounding. There's a demo on the top of the page to try it out.

Comments

Add your Comments

Feel free to leave a comment about this post.

- Feel Free to add HTML to your comment!