############################################################################### # FILE: TTSGaimPlugin.pl # AUTHOR: Tobias Gehrig , # DATE: 2004-07-06 # DESCRIPTION: This Gaim plugin feeds received text to a text reader along # with the desired language. # Based on GAIMFestival.pl by Matt Davis # 03/17/01 # For Gaim version 0.59.1 # LICENSE: GPL ############################################################################### use Gaim; %PLUGIN_INFO = ( perl_api_version => 2, name => "Text-to-speech plugin", version => "0.1", summary => "synthesizes the IM message through mbrola.", description => "This Gaim plugin feeds received text to a text reader along with the desired language.", author => "Tobias Gehrig ", url => "http://www.gehrignet.de/", load => "plugin_load", unload => "plugin_unload" ); sub plugin_init { return %PLUGIN_INFO; } sub plugin_load { my $plugin = shift; Gaim::signal_connect(Gaim::Conversations::handle, "received-im-msg", $plugin, \&sayText, 0); } sub plugin_unload { my $plugin = shift; } sub sayText { my ($account, $senderName, $message, $flags) = @_; $alias = Gaim::BuddyList::Buddy::get_alias_only(Gaim::BuddyList::find_buddy($account, $senderName)); if ($alias eq ""){ $alias = $senderName; } $_ = $message; 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"){ $message = "$alias sagt $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/tobias/bin/sag_was \"$message\""); } } return(0); # the message should also be displayed on screen so we return 0 }