Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
good chemistry is complicated,
and a little bit messy-LW
 
PerlMonks

Monktalk

by httptech (Chaplain)
 | Log in | Create a new user | The Monastery Gates | Super Search | 
 | Seekers of Perl Wisdom | Meditations | PerlMonks Discussion | 
 | Obfuscation | Reviews | Cool Uses For Perl | Perl News | Q&A | Tutorials | 
 | Poetry | Recent Threads | Newest Nodes | Donate | What's New | 

on Jun 01, 2000 at 21:53 UTC ( #15869=sourcecode: print w/ replies, xml ) Need Help??

Category: PerlMonks Clients
Author/Contact Info Joe Stewart aka httptech
Description: Speech interface to chatterbox, using festival server for the text-to-speech processing. You need to have the festival daemon running and install the Speech::Festival module.

Since it's based on ZZamboni's Chatterbox Client you will need to download his module as well.

#!/usr/bin/perl
# monktalk.pl - Talking Perl Monks
# By Joe Stewart
# Mainly just a hack to the sample driver program for PerlMonksChat.pm
# by Diego Zamboni, May 2000.
#
# Use:
#  monktalk.pl -l Username
#      Asks for your password. Stores cookies in ~/.pm-cookie.
#      This is only necessary the first time you use it. After that it
+ uses
#      the cookie automatically.
# Type messages to send
# Type /checkoff <number> to remove personal messages (this is the equ
+ivalent
#  of checking on them in the web page).
#
use strict;
use PerlMonksChat;
use IO::Select;
use Text::Wrap qw(wrap);
use Speech::Festival;

$| = 1;
$SIG{'INT'} = \&endit;

my $festival = new Speech::Festival;
conn $festival || warn "Could not connect to festival: $!";

my $user;
my $passwd;

my $usecolor=1;
my $color_username="";
my $color_personalmsg="";
my $color_sysmsg="";
my $color_normal="";

if ($ARGV[0] && $ARGV[0] eq "-l") {
  shift @ARGV;
  $user=shift @ARGV or die "User expected as argument to -l\n";
  print "Password? ";
  $passwd=<STDIN>;
  chomp $passwd;
}

my $period=shift @ARGV || 10;

if ($usecolor) {
  eval "use Term::ANSIColor";
  unless ($@) {
    $color_username=color('BOLD GREEN');
    $color_personalmsg=color('YELLOW BOLD');
    $color_sysmsg=color('RED');
    $color_normal=color('reset');
  }
}

my $p=PerlMonksChat->new();
$p->add_cookies;
if ($user) {
  $p->login($user, $passwd);
}

my $s=IO::Select->new;

$s->add(\*STDIN);
  while (1) {
    my @lines = map { s/^(<[^>]+>)/$color_username$1$color_normal/;
                s/^(\(\d+\)\s*\*.*)$/$color_personalmsg$1$color_normal
+/;
                wrap("", "\t", "$_\n") } $p->getnewlines(1);
    for (@lines) {
        print;
        &speak_to_me($_);
    }
    my @ready=$s->can_read($period);
    if (@ready) {
      foreach (@ready) {
        my $line=<$_>;
        chomp $line;
        if ($line =~ /^\/?(checkoff|co)\s+/ && (my @ids=($line=~/(\d+)
+/g))) {
          $p->checkoff(map { 'deletemsg_'.$_ } @ids);
          print $color_sysmsg, "* Done *", $color_normal,"\n";
        }
        elsif ($line =~ /^\s*\/quit\s*$/) {
          exit;
        }
        else {          $p->send($line);
        }
      }
    }
  }

sub speak_to_me($) {
    my $text = shift;
    $text =~ s/^.*?\s+//;
    request $festival "(SayText \"$text\")";
}

sub endit {
    print "Disconnecting from Festival: ";
    disconnect $festival;
    exit;
}

Comment on Monktalk
Download Code
RE: Monktalk
by KM (Priest) on Jun 07, 2000 at 21:58 UTC
    Just FYI.. I showed this to Kevin Lenzo (one of the Festival people) since it is always good to know how your software is being used. And he said 'neato!'. Just thought you would like to know the feedback :)

    Cheers,
    KM

Back to Code Catacombs

Login:
Password
remember me
What's my password?
Create A New User

Node Status?
node history
Node Type: sourcecode [id://15869]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (19)
BrowserUk
holli
Gavin
johngg
CardinalNumber
Khen1950fx
jethro
jaldhar
kennethk
thezip
Eyck
pileofrogs
LanX
pemungkah
trwww
ssandv
MikeDexter
lorick95
im2
As of 2010-02-09 22:24 GMT
Sections?
The Monastery Gates
Seekers of Perl Wisdom
Meditations
PerlMonks Discussion
Categorized Q&A
Tutorials
Obfuscated Code
Perl Poetry
Cool Uses for Perl
Perl News
Information?
PerlMonks FAQ
Guide to the Monastery
What's New at PerlMonks
Voting/Experience System
Tutorials
Reviews
Library
Perl FAQs
Other Info Sources
Find Nodes?
Nodes You Wrote
Super Search
List Nodes By Users
Newest Nodes
Recently Active Threads
Selected Best Nodes
Best Nodes
Worst Nodes
Saints in our Book
Leftovers?
The St. Larry Wall Shrine
Offering Plate
Awards
Craft
Snippets Section
Code Catacombs
Quests
Editor Requests
Buy PerlMonks Gear
PerlMonks Merchandise
Planet Perl
Perlsphere
Use Perl
Perl.com
Perl 5 Wiki
Perl Jobs
Perl Mongers
Perl Directory
Perl documentation
CPAN
Random Node
Voting Booth?

What level of existential comfort do you require?

Palace
Executive suite at the best hotel
Regular hotel in a decent part of town
Motel
Boarding house
Sleeping Bag on Couch in Basement
Any port in a storm
Camping under the freeway overpass
Jail
Other

Results (283 votes), past polls