Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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: # http://www.windowsitpro.com/WindowsScripting/Article/ArticleID/20796 +/20796.html # CB2Speech.pl 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{http://www.perlmonks.org/index.pl?node_id=207304}; 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; } }
planetscape

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

Title:
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 or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2022-09-30 21:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (126 votes). Check out past polls.

    Notices?