Skip to content

Instantly share code, notes, and snippets.

@fuba
Created December 24, 2009 20:22
Show Gist options
  • Save fuba/263353 to your computer and use it in GitHub Desktop.
Save fuba/263353 to your computer and use it in GitHub Desktop.
+ julius, mecab, saykana, ffmpeg インストールする
+ dictation-kit もってくる
+ dictation-kit-v4.0/fast.jconf の -input を rawfile にする
+ wav2text.pl の fast.jconf のパスを修正
+ 実行
$ cat textfile | perl saykana_wrapper.pl /tmp/sample.wav && wav2text.pl /tmp/sample.wav
+ textfile の内容がへんなテキストになって楽しい
#!/usr/bin/perl
use utf8;
use strict;
use warnings;
use Encode;
my $filename = shift or die 'specify filename with suffix (.wav, mp3, ...)';
my $text = decode_utf8(do { local $/; <STDIN> });
$text =~ s/[\n。]/   /g;
open my $mecab, '|-', "mecab -Oyomi | SayKana -f - -o /tmp/sample.aiff";
print $mecab encode_utf8($text);
close $mecab;
system("ffmpeg -y -i /tmp/sample.aiff -ar 16000 $filename");
#!/usr/bin/perl
use strict;
use warnings;
my $wavfile = shift;
my $julius = `echo $wavfile | julius -charconv EUC-JP UTF-8 -C src/dictation-kit-v4.0/fast.jconf`; # ここ編集
$julius =~ /sentence\d+\:\s+([^\r\n]*)/;
print $1."\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment