/[mbrola]/trunk/mbrola.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/mbrola.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by dpavlin, Sat Aug 5 12:13:01 2006 UTC revision 3 by dpavlin, Sat Aug 5 12:44:39 2006 UTC
# Line 210  sub speak_hr { Line 210  sub speak_hr {
210          # FIXME: lj, nj, dľ          # FIXME: lj, nj, dľ
211          my @chars = split(//, $text);          my @chars = split(//, $text);
212    
213          my @pho = ({ char => '_', dur => [50] });          my @pho = ({ char => '_', dur => [ $silence->{word} ] });
214    
215          my ($g,$f) = ('','');          my ($g,$f) = ('','');
216    
# Line 225  sub speak_hr { Line 225  sub speak_hr {
225                          $c = $phonemes->{$c};                          $c = $phonemes->{$c};
226                  } elsif (defined( $token_to_grapheme->{$c} )) {                  } elsif (defined( $token_to_grapheme->{$c} )) {
227                          $c = $token_to_grapheme->{$c};                          $c = $token_to_grapheme->{$c};
                 } else {  
                         $pho[ $#pho ]->{dur}->[0] = $silence->{word};  
                         next;  
228                  }                  }
229    
230                  my $d = $durations->{$c} || $silence->{word};                  my $d = $durations->{$c} || $silence->{word};
231    
232                  my @dur = ( $d );                  my @dur = ( $d );
233    
234                  if ($first) {                  if ($last_c =~ m/[,\.!\? _]/) {
                         $first = 0;  
   
                         push @dur, ( 10, 120 );  
                 }  
   
                 if ($zarez) {  
                         $zarez = 0;  
                         push @dur, ( 10, 100 );  
                 }  
   
   
                 if ($c =~ m/[,\.!\? _]/) {  
235    
236                          my $from = $#{ $pho[ $i - 1 ]->{dur} };                          my $from = $#{ $pho[ $i - 1 ]->{dur} };
237                          $from = 3 if ($from > 3);                          $from = 3 if ($from > 3);
# Line 258  sub speak_hr { Line 243  sub speak_hr {
243                                  $tmpr += 30;                                  $tmpr += 30;
244                          }                          }
245    
246                          if ($c =~ m/,/) {                          # begining of sentence
247                                  $zarez = 1;                          push @dur, ( 10, 120 );
248                                  @dur = ( $silence->{comma} );                  }
                         } else {  
                                 @dur = ( $silence->{sentence} );  
                                 $first = 1;  
                         }  
249    
250                    if ($c =~ m/\s/) {
251                            $pho[ $#pho ]->{dur}->[0] += $silence->{word};
252                            $last_c = $c;
253                            next;
254                    } elsif ($c =~ m/[\.!\?]/) {
255                            $pho[ $#pho ]->{dur}->[0] += $silence->{word};
256                            push @pho, {
257                                    char => '_',
258                                    dur => [ $silence->{word} ],
259                            };
260                            $last_c = $c;
261                            next;
262                    } elsif ($c =~ m/,/) {
263                            push @dur, ( 10, 100 );
264                  }                  }
265    
266                  # same last chars? double duration                  # same last chars? double duration
# Line 278  sub speak_hr { Line 273  sub speak_hr {
273                  if (defined($recovery->{ $last_c . $c })) {                  if (defined($recovery->{ $last_c . $c })) {
274                          push @pho, {                          push @pho, {
275                                  char => '_',                                  char => '_',
276                                  dur => [ $silence->{word} * $speed ],                                  dur => [ $silence->{word} ],
277                          };                          };
278                  }                  }
279    
# Line 291  sub speak_hr { Line 286  sub speak_hr {
286                  $f .= $c;                  $f .= $c;
287          }          }
288    
289          push @pho, { char => '_', dur => [50] };          push @pho, { char => '_', dur => [ $silence->{sent} ] };
290    
291          warn "# pho = ",dump(@pho),$/;  #       warn "# pho = ",dump(@pho),$/;
292    
293          my $out;          my $out;
294    
# Line 314  while ( defined ($_ = $term->readline($p Line 309  while ( defined ($_ = $term->readline($p
309    
310          open(my $fh, "| $mbrola - tmp.wav") || die "can't open $mbrola: $!";          open(my $fh, "| $mbrola - tmp.wav") || die "can't open $mbrola: $!";
311    
312          print $OUT ">>> $g\n>>> $f\n$out\n";          print $OUT ">>> $g\n<<< $f\n";
313    
314          print $fh $out || die "can't pipe to $mbrola";          print $fh $out || die "can't pipe to $mbrola";
315          close($fh) || die "error closing pipe to $mbrola";          close($fh) || die "error closing pipe to $mbrola";
316    
317            $out =~ s/\n/ | /gs;
318            print $OUT "# $out\n";
319    
320          system 'play tmp.wav';          system 'play tmp.wav';
321    
322  }  }

Legend:
Removed from v.2  
changed lines
  Added in v.3

  ViewVC Help
Powered by ViewVC 1.1.26