############################################################################### # FILE: TTSGaimPlugin.pl # AUTHOR: Marc Spoorendonk # DATE: 2002-12-13 # DESCRIPTION: This Gaim plugin feeds received text to a text reader along # with the desired language. Language setting is read from the # users alias: "Marc Spoorendonk (nl)" # Based on GAIMFestival.pl by Matt Davis # 03/17/01 # For Gaim version 0.59.1 # LICENSE: GPL ############################################################################### print "Text-to-speech plugin: Loading..... "; GAIM::register("TextToSpeech", "0.0.1", "", ""); GAIM::add_event_handler("event_im_recv", "sayText"); sub sayText { $senderId = $_[0]; $senderName = $_[1]; $messageStr = $_[2]; @userInfo = GAIM::user_info($senderId, $senderName); $alias = $userInfo[1]; # alias can be "Marc Spoorendonk (nl)" # this language is stripped $_ = $alias; if(s/^.*\(([a-z]{2})\)/$1/g) { $language=$_; } #remove country identifyer $_ = $alias; s/^(.*)\([a-z]{2}\)/$1/g; $alias = $_; $_ = $messageStr; s/<(?:[^>\'\"]*|([\'\"]).*?\1)*>//gs; #Parse out most HTML. # from http://www.rocketaware.com/perl/perlfaq9/How_do_I_remove_HTML_from_a_stri.htm s/\"//g; # via the command line s/\\//g; $message = $_; if ($message ne "null" && $language ne ""){ if($language eq "nl") { $verb="zegt"; } else { $verb="says"; } $message = "$alias $verb: $message"; print "TTS: $message\n"; # The fork allows the message to be displayed as it is being said. If # system was used, the message would not display until after the text reader was # done saying it. unless (fork) { #exec("/home/marc/project/tts/sayText \"$message\" $language"); exec("/home/marc/project/tts/queueText \"$message\" $language"); } } return(0); # the message should also be displayed on screen so we return 0 } print "OK\n"; # loaded successfully