#!/bin/bash # sayit -- [Mac OS X only] uses the Mac "say" command to # read whatever's specified setglobal dosay = ""$[which say] --quality=127"" setglobal format = ""$[which fmt] -w 70"" setglobal voice = ''"" # default system voice setglobal rate = ''"" # default to the standard speaking rate proc demovoices { # offer up a sample of each available voice setglobal voicelist = $[ say -v '?' | grep "en_" | cut -c1-12 | sed 's/ /_/;s/ //g;s/_$//] if test $1 = "list" { echo Available voices: $[echo $voicelist | sed 's/ /, /g;s/_/ /g] | $format echo "HANDY TIP: use \"$[basename $0] demo\" to hear all the voices" exit 0 } for name in [$voicelist] { setglobal myname = $[echo $name | sed 's/_/ /] echo "Voice: $myname" $dosay -v $myname "Hello! I'm $myname. This is what I sound like." } exit 0 } proc usage { echo "Usage: sayit [-v voice] [-r rate] [-f file] phrase" echo " or: sayit demo" exit 0 } while getopts "df:r:v:" opt { match $opt { with d demovoices list with f setglobal input = $OPTARG with r setglobal rate = ""-r $OPTARG"" with v setglobal voice = $OPTARG } } shift $shExpr('$OPTIND - 1') if test $Argc -eq 0 -a -z $input { $dosay "Dude! You haven't given me any parameters to work with." echo "Error: no parameters specified. Specify a file or phrase" exit 0 } if test $1 = "demo" { demovoices } if test ! -z $input { $dosay $rate -v $voice -f $input } else { $dosay $rate -v $voice "$ifsjoin(Argv)" } exit 0