muppet's alphabet teacher



Hi, this is a small, but "fun for a kid" enhancment,
of muppet's earlier post. It uses "flite", a small
speech synthesis tool to audibilize the letters.

See http://www.speech.cs.cmu.edu/flite

It actually speaks any pressed key, and with a bit of keypress-genius,
someone could extend it to more than [:alnum:]]

#!/usr/bin/perl -w

# muppet
# This simple bit of code has helped my toddlers learn letters and  
# numbers for quite some time.  I thought i should share it, if for  
# nothing else than the line where i set the font size.  :-)

use strict;
use Gtk2 -init;

my $window = Gtk2::Window->new;
my $label = Gtk2::Label->new ("W");
my $font_desc = Gtk2::Pango::FontDescription->from_string ("Sans Bold");
$font_desc->set_size (512000);
$label->modify_font ($font_desc);
$window->add ($label);
$window->signal_connect (key_press_event => sub {
        my ($widget, $event) = @_;
        my $key = uc Gtk2::Gdk->keyval_name ($event->keyval);
        $label->set_text ($key) if $key =~ m/^[[:alnum:]]$/;
        
        #added by zentara
        Gtk2->main_iteration while Gtk2->events_pending;
        system("flite -t $key");
});

$window->signal_connect (destroy => sub { Gtk2->main_quit });
$window->show_all;
Gtk2->main;
__END__


zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]