Spoken Log

I've been trying to keep closer tabs on this site so that I can understand the ways people act here. This weekend I added voice synthesis. This turns out to be a lot of fun and pretty informative too. I'm writing to other server operators to encourage them to give this a try. -- WardCunningham

My mac has a command line program that will pronounce text. If I want it to say hello to the world I would type:

   say hello world
I can add this to my perl wiki server by adding the line:

   system("say $page&");
Place it in wiki.cgi just after where it figured out the requested page. I add the & to the command so that the server doesn't wait for the speaking to finish before serving the page. This could be a lot of fun if you're running a wiki for a group of people who happen to sit near the server. A more useful variation might be to add the speaking to the edit.cgi script. This would announce which pages are being edited so that people can avoid conflicts.

Now I don't actually sit anywhere near my server so I had to monitor its activity remotely. I'm used to using tail -f to watch my server logs. This works fine through secure shell too:

   ssh c2.com 'tail -f /var/log/httpd/access_log'
So I wrote this into a perl script, something like:

   open(L, "ssh c2.com 'tail -f /var/log/httpd/access_log'|");
   while(<L>) {
     system("say $1&") if /([A-Z][a-z]+([A-Z][a-z]+)+)/;
This looks for wiki names in the log and pronounces them as fast as they come. I put the system call into a subroutine and added a sleep to limit the rate to one a second.

   sub say {
     system("say $1&");
Longer names take more than a second to say so the talking can overlap. But this is easy to understand so long as the starts are staggered.

I've added a second voice for more rare events, like posts back to the server for saved pages:

   system("say -v Bruce post&") if /POST/;
Bruce is easy to understand even when my default voice, Victora, is gabbing away. I've actually added five or six triggers for Bruce. When he gets going I know someone is doing something weird to my server.

I've also found it useful to ignore the robots. With them crusing through my site the talking gets way too complicated. I added this right inside the while loop:

   next if /googlebot.com/;
You will have to tune what you look for and how you say it so that you get a good feel for what is going on moment by moment. Once you have it working, try watching the log the old fashion way in a separate window. You'll find more things you might want to pronounce.

Cool idea, Ward, but where did you get the command line program 'say'? All I can do is
 osascript -e 'say "Hello world"'
which means I'm telling my shell to tell AppleScript to say something. -- ElizabethWiethoff

say is available in 10.3.

Aha! I'm 10.2. So if I get a RoundTuit I'll write a script that wraps the osascript call.

If you have a windows machine and want to use PythonLanguage, this might help. I wrote it when I first saw Ward's post. (You have to have MS Speech SDK 5.1 http://www.microsoft.com/speech/download/sdk51 , Python http://www.python.org , and python win32all module http://sourceforge.net/project/showfiles.php?group_id=78018 installed on your computer)

    import win32com.client

MARY_VOICE='Microsoft Mary' voice= win32com.client.Dispatch("SAPI.SpVoice") default_voice=voice.Voice.GetDescription() voice.Speak("Hello %s. I'm %s. Nice to meet you."%(MARY_VOICE,default_voice)) voice.Voice=voice.GetVoices("Name=%s"%MARY_VOICE, "Language=409").Item(0) voice.Speak("Hello %s. I am glad to meet you."%default_voice) voice.WaitUntilDone(-1)
There are three voices included in the sdk : Mary, Mike and Sam. Take a look at the speech sdk in msdn.

If you want to use wsh instead, make a file named speak.pys:

    voice = WScript.CreateObject("Sapi.SpVoice")  
    voice.Speak("Hello world") 
and run "wscript speak.pys"

-- JuneKim

See: VoiceOfWiki WikiWithMoreThanPages Related: SoftwareAsMusic

View edit of July 16, 2005 or FindPage with title or text search