Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (13)
    As of 2014-08-29 16:20 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The best computer themed movie is:











      Results (282 votes), past polls