Pocketsphinx_continuousの出力をファイルにリダイレクトする

Pocketsphinx_continuousの出力をファイルにリダイレクトする

私は醜い命令を持っています:

pocketsphinx_continuous -samprate 48000 -nfft 2048 -hmm /usr/local/share/pocketsphinx/model/en-us/en-us -lm 9745.lm -dict 9745.dic -inmic yes

分解:ノイズを聞き、ノイズが検出されたらそれを聞いて音声認識を実行します。

コマンド出力には多くのゴミがあり、1行だけ重要です。以下は音声認識の出力です。

READY....
Listening...
INFO: cmn_prior.c(131): cmn_prior_update: from < 21.18 -11.87  6.18  0.77  4.42 -0.76  1.99  8.43  2.83 -1.46  3.80  6.19  3.71 >
INFO: cmn_prior.c(149): cmn_prior_update: to   < 23.28 -5.11  8.81 -0.28  0.06 -0.83  0.94  6.68  0.42  1.07  4.00  7.34  4.32 >
INFO: ngram_search_fwdtree.c(1553):      814 words recognized (9/fr)
INFO: ngram_search_fwdtree.c(1555):    60871 senones evaluated (684/fr)
INFO: ngram_search_fwdtree.c(1559):    37179 channels searched (417/fr), 6846 1st, 21428 last
INFO: ngram_search_fwdtree.c(1562):     1415 words for which last channels evaluated (15/fr)
INFO: ngram_search_fwdtree.c(1564):     2626 candidate words for entering last phone (29/fr)
INFO: ngram_search_fwdtree.c(1567): fwdtree 0.66 CPU 0.742 xRT
INFO: ngram_search_fwdtree.c(1570): fwdtree 3.36 wall 3.780 xRT
INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 21 words
INFO: ngram_search_fwdflat.c(948):      655 words recognized (7/fr)
INFO: ngram_search_fwdflat.c(950):    40095 senones evaluated (451/fr)
INFO: ngram_search_fwdflat.c(952):    31447 channels searched (353/fr)
INFO: ngram_search_fwdflat.c(954):     1794 words searched (20/fr)
INFO: ngram_search_fwdflat.c(957):     1006 word transitions (11/fr)
INFO: ngram_search_fwdflat.c(960): fwdflat 0.29 CPU 0.326 xRT
INFO: ngram_search_fwdflat.c(963): fwdflat 0.30 wall 0.333 xRT
INFO: ngram_search.c(1253): lattice start node <s>.0 end node </s>.70
INFO: ngram_search.c(1279): Eliminated 1 nodes before end node
INFO: ngram_search.c(1384): Lattice has 127 nodes, 473 links
INFO: ps_lattice.c(1380): Bestpath score: -2298
INFO: ps_lattice.c(1384): Normalizer P(O) = alpha(</s>:70:87) = -132973
INFO: ps_lattice.c(1441): Joint P(O,S) = -156371 P(S|O) = -23398
INFO: ngram_search.c(875): bestpath 0.01 CPU 0.011 xRT
INFO: ngram_search.c(878): bestpath 0.00 wall 0.005 xRT
HELLO

これがHELLO唯一の重要な点です。何とかファイルに出力したいです。

ファイルを除くすべてを出力し、コマンドラインに出力しないことを>foo.txt除いて、動作するコマンドの最後に追加しようとしました。HELLOHELLO

私は追加しようとしましたが、これは消える&> foo.txt 2> foo.txt >> foo.txtたびに出力が必要な場所に移動します。READY....Listening...HELLO

どのような方法でファイルをどのようにHELLO指定できますか?他のものがあるかどうかにかかわらず、他のものを切り取ることができます。

ベストアンサー1

この試み:

pocketsphinx_continuous -samprate 48000 -nfft 2048 -hmm \
/usr/local/share/pocketsphinx/model/en-us/en-us -lm 9745.lm -dict 9745.dic \
-inmic yes 2>&1 | tee ./full-output.log | grep -v --line-buffered '^INFO:'

これは記録されますすべてで始まる./full-output.logがコンソールからで始まるすべての出力を隠しますINFO:2>&1すべての出力が標準出力だけでなく、一連のパイプを介して強制されるように、標準エラーを標準出力にリダイレクトします。

含まれていない他の行を非表示にするには、拡張構文をINFO:使用できます。|grep

egrep -v --line-buffered '^INFO:|^ERROR:'

このオプションを使用すると、出力が完全に完了するのを待た--line-bufferedなくなります。greppocketsphinx_continuous

編集する

pocketsphinx_continuousまた、必要なものすべてを標準出力に入れ、不要なものすべてを標準エラーに入れた可能性があります。したがって、次のことを試すことができます。

pocketsphinx_continuous -samprate 48000 -nfft 2048 -hmm \
/usr/local/share/pocketsphinx/model/en-us/en-us -lm 9745.lm -dict 9745.dic \
-inmic yes 2>./unwanted-stuff.log | tee ./words.log

これにより、標準エラーのすべての内容がに記録され、./unwanted-stuff.log標準出力のすべての内容が記録されます./words.log

おすすめ記事