$WAVFILE = "/home/sve204/sphinx/name-in.wav"; # Monitor put's the -in on the file, CHANGE THIS LINE $SPHINXDIR = "/usr/share/sphinx2/"; use Speech::Recognizer::SPX qw(:uttproc :fbs $SPHINXDIR); use Speech::Recognizer::SPX::Server; use Config; $loaded = 1; fbs_init({-live => 'FALSE', -samp => 8000, -adcin => 'TRUE', -ctloffset => 0, -ctlcount => 100000000, -cepdir => "$SPHINXDIR/model/lm/names", # CHANGE THIS LINE -datadir => "$SPHINXDIR/model/lm/names", # CHANGE THIS LINE -agcmax => 'FALSE', -langwt => 6.5, -fwdflatlw => 8.5, -rescorelw => 9.5, -ugwt => 0.5, -fillpen => 1e-10, -silpen => 1e-10, #0.005, -inspen => 0.65, -top => 1, -topsenfrm => 3, -topsenthresh => -70000, -beam => 2e-06, -npbeam => 2e-06, -lpbeam => 2e-05, -lponlybeam => 0.0005, -nwbeam => 0.0005, -fwdflat => 'FALSE', -fwdflatbeam => 1e-08, -fwdflatnwbeam=> 0.0003, -bestpath => 'TRUE', -kbdumpdir => "$SPHINXDIR/model/lm/names", # CHANGE THIS LINE -lmfn => "$SPHINXDIR/model/lm/names/names.lm", # CHANGE THIS LINE -dictfn => "$SPHINXDIR/model/lm/names/names.dic", # CHANGE THIS LINE -phnfn => "$SPHINXDIR/model/hmm/communicator/sphinx_2_format/phone", -mapfn => "$SPHINXDIR/model/hmm/communicator/sphinx_2_format/map", -hmmdir => "$SPHINXDIR/model/hmm/communicator/sphinx_2_format", -hmmdirlist => "$SPHINXDIR/model/hmm/communicator/sphinx_2_format", -ndictfn => "$SPHINXDIR/model/hmm/communicator/sphinx_2_format/noisedict", '-8bsen' => 'TRUE', -sendumpfn => "$SPHINXDIR/model/hmm/communicator/sphinx_2_format/sendump", -cbdir => "$SPHINXDIR/model/hmm/communicator/sphinx_2_format"}); open WAV, "<$WAVFILE" or die "couldn't open $WAVFILE: $!"; uttproc_begin_utt(); my $count = 0; while (defined(my $b = read WAV, my($buf), 4096)) { last if $b == 0; $count += $b; uttproc_rawdata($buf, 1) or die "uttproc_rawdata failed"; } uttproc_end_utt(); my ($fr, $hyp) = uttproc_result(1); fbs_end(); print "$hyp";