Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Creating a talking cat in Jaguar UNIX
I recently found a very fun reimplementation of UNIX cat that adds OS X's capability for speech synthesis. The binary is available from gnufoo.org. To install, place the file in ~/bin and run chmod -x ~/bin/cat to make it executable. There's also a patch for the system-wide cat available.

Then run ~/bin/cat -a and type something. Hit return, and your Mac speaks the text back to you. Or give it a filename, i.e. ~/bin/cat -a tellmeastory.txt and the machine will read you its contents. Since it would be easy to call the 'talking cat' from a shell script, there are possibilites for spoken error messages and the like.
    •    
  • Currently 2.00 / 5
  You rated: 2 / 5 (2 votes cast)
 
[6,578 views]  

Creating a talking cat in Jaguar | 26 comments | Create New Account
Click here to return to the 'Creating a talking cat in Jaguar' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
I'll use this to flaunt my uptime
Authored by: silas on Oct 08, '02 10:59:10AM

I'll just put this in a daily crontab for all the windows users in the office to hear:

# uptime | cut -d' ' -f3-7 | cat -a

Yeah!

Chris



[ Reply to This | # ]
It just wont work for me
Authored by: harpdog on Oct 09, '02 01:00:23PM

I am using 10.2.1 I have developer tools installed and xwindows fink and a few other apps.

I have downloaded the binary of cat and placed it in ~/bin

i have renamed my original cat file to cat.old in /bin.

I cd into my home/bin directory and type

./cat -a

and I get 'permission denied' yet the file does belong to me.

anyway i try sudo cat -a and I get 'command not found'

What gives?



[ Reply to This | # ]
It just wont work for me
Authored by: rjbailey on Oct 09, '02 05:12:47PM

You probably didn't make it executable: type

chmod 755 cat
or
sudo chmod 755 cat

to make it executable. (As per suggestions, I renamed it kat and put it in /usr/local/bin.)



[ Reply to This | # ]
It just wont work for me
Authored by: brandondrew on Nov 12, '04 02:48:00AM

try this instead:
say `uptime | cut -d' ' -f3-7`

---
--
Brandon Z



[ Reply to This | # ]
Fun speech Easter Egg
Authored by: silas on Oct 08, '02 11:04:00AM

I just noticed that if you do

# echo 'Mac OS X Rocks' | cat -a

the system speaks

"Mac Oh-Ess Ten Rocks"

(instead of "Oh-Ess Exx"). Looks like they trained it to recognize the product name as a phrase....cool.



[ Reply to This | # ]
Safer?
Authored by: ClarkGoble on Oct 08, '02 01:41:34PM

Given the limited functionality, I'd feel better just compiling their cat and calling it something else.



[ Reply to This | # ]
What a missed opportunity
Authored by: babbage on Oct 08, '02 02:29:36PM

A talking 'cat'? Why wasn't this named 'cheshire'? That name would be much funnier :-)



[ Reply to This | # ]
Homegrown solution
Authored by: thevas on Oct 08, '02 03:34:38PM
You can get the same effect with
sed -e 's/.*/say "&"/' | osascript
Or, just make a tcsh alias:
alias say 'sed -e 's/.*/say "&"/' | osascript'
Note: You'll need a backslash before each quote except the outermost ones. I can't figure out how to make that display! Now 'cat foo.txt | say' speaks out the file foo, and 'uptime | cut -d' ' -f3-7 | say' speaks out your uptime, etc.

[ Reply to This | # ]
Homegrown solution
Authored by: tfriesen on Oct 10, '02 12:01:55AM

Quoting this is non-trivial for those folks who don't live and breathe regular expressions.

It should read:
alias say 'sed -e '\\''s/.*/say '\\\\\\"'&'\\\\\\"'/'\\'' | osascript'

Honest!

Cheers,
Tom Friesen



[ Reply to This | # ]
Homegrown solution
Authored by: tfriesen on Oct 10, '02 12:07:05AM

Uh oh. Preview wasn't totally honest with me on that last one. Each double backslash in the previous post should only be a single backslash.

As in...
alias say 'sed -e '\''s/.*/say '\\\"'&'\\\"'/'\'' | osascript'

Mea culpa.

Tom Friesen



[ Reply to This | # ]
Homegrown solution
Authored by: thevas on Oct 10, '02 12:41:01AM
Or, you can just make tcsh quote things more "normally" with
set backslash_quote. Then you need just one backslash per inner quote.

[ Reply to This | # ]
put it in /usr/local/bin
Authored by: hayne on Oct 08, '02 05:07:25PM

The hint said to put this modified version of 'cat' into the /bin directory. This is a very bad idea. You should never overwrite the standard stuff that comes with the OS. Instead, you should put such extras into the /usr/local directory - e.g. into /usr/local/bin for executable programs like this. Of course, you need to modify your path to make it find the version in /usr/local/bin - but that is part of the point: anyone (any script) who does not have the /usr/local/bin in their path will get the standard 'cat' that they are expecting.



[ Reply to This | # ]
put it in /usr/local/bin
Authored by: hayne on Oct 08, '02 05:11:29PM

Oops - sorry, I didn't read the hint carefully enough. It had suggested puttng it in ~/bin not in /bin as I had initially read. So consider my comment erased (if that were possible!).



[ Reply to This | # ]
put it in /usr/local/bin
Authored by: BraindeadMac on Oct 09, '02 07:47:38AM

in the posters defense, he actually said to put it in ~/bin, not /bin, ~/bin of course being
/Users/yournamehere/bin....



[ Reply to This | # ]
put it in /usr/local/bin
Authored by: BraindeadMac on Oct 09, '02 07:48:17AM

in the posters defense, he actually said to put it in ~/bin, not /bin, ~/bin of course being
/Users/yournamehere/bin....



[ Reply to This | # ]
Nice
Authored by: Anonymous on Oct 08, '02 07:19:47PM

The binary works fine in 10.1.5 and I renamed it "kat"
and stuck it in my ~/bin directory.



[ Reply to This | # ]
Nope
Authored by: hotsoup on Oct 08, '02 07:56:31PM

This is to complicated of a tip for me... I think i'll pass.



[ Reply to This | # ]
Nope
Authored by: babbage on Oct 09, '02 01:03:52AM
What's complicated? Follow the link and there's a binary & a manpage file, just waiting for you to download them & copy to /usr/local. From then on, they can be used the same way standard Unix cat is used -- except that with the -a flag it'll speak whatever you filter through it. Rockin! :-)

Before I went home tonight, I banged out a little Perl script that calls the fortune command every 15 or 20 minutes, reading the joke/riddle/quote aloud through this version of cat. Now if I can just get someone *else's* computer to do this on a seemingly random basis that would be great... :-)

[ Reply to This | # ]

Nope
Authored by: evands on Oct 09, '02 02:14:26AM

Nonono, if you want to be able to install that sort of prank without the other person knowing, compiling an OS X command tool is no good - you'll want to figure out a way to run it under Windows. From there, all is simple. ;)



[ Reply to This | # ]
Nope
Authored by: babbage on Oct 09, '02 08:41:16AM

Well no, then the tricky bit would be to get one of my co-workers to run Windows -- everyone's using OSX or Linux, and the only system speech software I know of is the stuff that comes with Macs. Now if you could pipe the Macintalk sound output to a WAV or MP3 file or something, then the trick would be to get that file to play on a remote computer. This is much more doable, provided that we can generate the files on the fly... :-)



[ Reply to This | # ]
Nope
Authored by: aranor on Oct 09, '02 09:51:32PM

You could simply use an applescript to get their computer to talk. If you have SSH into their computer, just SSH in and use the 'osascript' command. If you don't have SSH but you have remote applescript capability, use an applescript or use 'osascript' with remote appleevents.

On a related note, I used this new 'cat' for a very cool purpose. I wrote a small PHP page that displays a text box, and when you hit the submit button it makes the computer speak whatever was typed! I tried this using
'osascript' and it didn't work because, when run from the webserver, 'osascript' didn't have access to the windowserver. I tried writing my own quick tool to do it, but for some reason speech simply didn't happen. So this 'cat' tool rocks, because now random people can make my computer speak! Of course, I need to publish my IP for that to happen, and I keep forgetting it (and I'm behind an IP mask so I can't easily figure it out). Oh well.



[ Reply to This | # ]
Nope
Authored by: babbage on Oct 10, '02 01:00:09AM

Uhh, maybe I wasn't clear. I've got access to a Mac, as do a couple of co-workers, but the majority of the other computers are Linux. The better general solution would be to capture the audio output (something like {osascript -e 'say "hello world" ' >hello.mp3 } or... yeah, something like that) and then just push the sound file to whatever platform can play mp3s (all of 'em). Hmm...



[ Reply to This | # ]
Nope
Authored by: osxpounder on Dec 20, '02 05:11:06PM

Your idea reminds me of a prank I pulled years ago on an OS9 user.

Just be sure that, once you get them to run the file, Applescript makes it impossible to delete. I had made a recording that played back every 15 min., and when my ill-fated user located the offending file and dragged it to the Trash [& emptied it], she was surprised to hear it 15 minutes later, chiming away.

The Applescript was written to quietly and invisibly undelete the file and return it to its original folder every time it was dropped into the Trash. Took her forever to figure that one out.

Ah, good times.



[ Reply to This | # ]
I protest totally to using the cat command
Authored by: loekjehe on Oct 09, '02 08:52:25AM

As a developer I sincerely recommend not to use standard operating system command names for such purpose (even while being placed in ~/bin). Modifying system commands in this way would make your system unreliable and non-standard. You'd indeed better rename the modified command to "kat" or any other new command name if you don“t want all sort of strange things to happen on your machine.



[ Reply to This | # ]
I protest totally to using the cat command
Authored by: babbage on Oct 10, '02 01:02:10AM

...hence my suggestion to name it 'cheshire', for the _Alice in Wonderland_ talking cat reference... :-)



[ Reply to This | # ]
New "say" command in Panther 10.3
Authored by: dzurn on Mar 01, '04 09:35:50PM
Now with Panther you can use the "say" command.

http://www.macosxhints.com/article.php?story=20031113181603909

I'm still trying to figure out how to change my Mac's pronunciation of my wife's name, though.

---
Madness takes its toll.
Please have exact change.

[ Reply to This | # ]