Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Thank you, atcroft!

Because I run WinXP and had trouble installing Festival under Cygwin, I modified this (slightly) to use Microsoft Direct Speech Synthesis (part of the Microsoft Speech API). My modifications were based largely on code found here, and of course, lots of assistance from, and hand-holding by, atcroft himself. (Thanks again!)

(99.99% of this is still atcroft's work, and he deserves the credit.)

#!/usr/bin/perl # by [atcroft] - from [id://465955] # *minor* mods by [planetscape], based largely on code found here: # +/20796.html # use strict; use warnings; use LWP::Simple; use XML::Simple; use Win32::OLE qw( EVENTS ); my $DirectSS = new Win32::OLE( "{EEE78591-FE22-11D0-8BEF-0060081841DE} +" ); Win32::OLE->WithEvents( $DirectSS, \&ProcessEvents, "{EEE78597-FE22-11 +D0-8BEF-0060081841DE}" ); my $fSpeaking; $| = 1; my $delay = 90; my $seen = 0; my ($max_retrievals); { my %to_run = ( days => 0, hours => 0, minutes => 30, seconds => 0, ); $max_retrievals = int( ( ( ( $to_run{days} * 24 + $to_run{hours} ) * 60 + $to_run{minutes} ) * 60 + $to_run{seconds} ) / $delay ); } my $display_messages = 0; my $xs = new XML::Simple; my $cb_xml_url = q{}; my $format = sprintf( qq{(%%0%dd) %%s - %%s: %%s\n}, length($max_retrievals) ); print length($max_retrievals), " ", $max_retrievals, "\n"; while ($max_retrievals) { my $said = 0; my $cb_xml = get($cb_xml_url) or die (qq{Could not retrieve CB XML ticker: $!\n}); my $ref = $xs->XMLin( $cb_xml, ForceArray => [q{message}] ) or die (qq{Could not parse CB XML: $!\n}); if ( exists( $ref->{message} ) ) { foreach my $message ( @{ $ref->{message} } ) { if ( $message->{message_id} > $seen ) { $seen = $message->{message_id}; my $Phrase = (join ( qq{\t}, $message->{author}, $message->{text} ) . qq{\n} ); $DirectSS->Speak( $Phrase ); $fSpeaking = 1; while( $fSpeaking ) { Win32::OLE->SpinMessageLoop(); Win32::Sleep( 100 ); } $said++; printf $format, $max_retrievals, scalar localtime $message->{epoch}, $message->{author}, $message->{text} if ($display_messages); } } print qq{Said: $said\n} if ($display_messages); } $max_retrievals--; sleep($delay); } sub ProcessEvents { my( $Obj, $Event, @Args ) = @_; if( 4 == $Event ) { $fSpeaking = 0; } }

In reply to Re: Chatterbox to Festival Server (TTS output) by planetscape
in thread Chatterbox to Festival Server (TTS output) by atcroft

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2023-12-02 22:38 GMT
Find Nodes?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?

    Results (19 votes). Check out past polls.