Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Interactive Text-to-Speech (Windows, Perl)

DZone's Guide to

Interactive Text-to-Speech (Windows, Perl)

·
Free Resource
This script calls the Windows OLE for the built in TTS. Type what you want the computer to say at the prompt and hit enter. To quit type ":q" (minus the quotation marks).



use Win32::OLE qw( EVENTS );

get_text();

sub get_text{
	$output_speech = 
  
   ;
	chomp($output_speech);
	if($output_speech ne ":q"){
		say_this();
		get_text();
	}
}

sub say_this{
	my $myTTS = new Win32::OLE( "Sapi.SpVoice" ); 
	$myTTS->Speak( "$output_speech" );
	while( $myTTS->{Speaking} )
	{
		Win32::OLE->SpinMessageLoop();
		Win32::Sleep( 100 );
	}
}

  
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}