--- trunk/mbrola.pl 2006/08/05 12:13:01 2 +++ trunk/mbrola.pl 2006/08/05 12:44:39 3 @@ -210,7 +210,7 @@ # FIXME: lj, nj, dľ my @chars = split(//, $text); - my @pho = ({ char => '_', dur => [50] }); + my @pho = ({ char => '_', dur => [ $silence->{word} ] }); my ($g,$f) = ('',''); @@ -225,28 +225,13 @@ $c = $phonemes->{$c}; } elsif (defined( $token_to_grapheme->{$c} )) { $c = $token_to_grapheme->{$c}; - } else { - $pho[ $#pho ]->{dur}->[0] = $silence->{word}; - next; } my $d = $durations->{$c} || $silence->{word}; my @dur = ( $d ); - if ($first) { - $first = 0; - - push @dur, ( 10, 120 ); - } - - if ($zarez) { - $zarez = 0; - push @dur, ( 10, 100 ); - } - - - if ($c =~ m/[,\.!\? _]/) { + if ($last_c =~ m/[,\.!\? _]/) { my $from = $#{ $pho[ $i - 1 ]->{dur} }; $from = 3 if ($from > 3); @@ -258,14 +243,24 @@ $tmpr += 30; } - if ($c =~ m/,/) { - $zarez = 1; - @dur = ( $silence->{comma} ); - } else { - @dur = ( $silence->{sentence} ); - $first = 1; - } + # begining of sentence + push @dur, ( 10, 120 ); + } + if ($c =~ m/\s/) { + $pho[ $#pho ]->{dur}->[0] += $silence->{word}; + $last_c = $c; + next; + } elsif ($c =~ m/[\.!\?]/) { + $pho[ $#pho ]->{dur}->[0] += $silence->{word}; + push @pho, { + char => '_', + dur => [ $silence->{word} ], + }; + $last_c = $c; + next; + } elsif ($c =~ m/,/) { + push @dur, ( 10, 100 ); } # same last chars? double duration @@ -278,7 +273,7 @@ if (defined($recovery->{ $last_c . $c })) { push @pho, { char => '_', - dur => [ $silence->{word} * $speed ], + dur => [ $silence->{word} ], }; } @@ -291,9 +286,9 @@ $f .= $c; } - push @pho, { char => '_', dur => [50] }; + push @pho, { char => '_', dur => [ $silence->{sent} ] }; - warn "# pho = ",dump(@pho),$/; +# warn "# pho = ",dump(@pho),$/; my $out; @@ -314,11 +309,14 @@ open(my $fh, "| $mbrola - tmp.wav") || die "can't open $mbrola: $!"; - print $OUT ">>> $g\n>>> $f\n$out\n"; + print $OUT ">>> $g\n<<< $f\n"; print $fh $out || die "can't pipe to $mbrola"; close($fh) || die "error closing pipe to $mbrola"; + $out =~ s/\n/ | /gs; + print $OUT "# $out\n"; + system 'play tmp.wav'; }