2016-06-28 15 views
-1

約1分の長さのサウンドファイルを分析すると、pocketsphinxはファイルを複数の結果に分割します。単一の発言を返すようにコードを変更する方法はありますか?私はcontinuous_test.pyに基づいてコードを使用しています。pocketsphinx:1つの結果として長い発声を返します。

#!/usr/bin/python 

from os import environ, path 

from pocketsphinx.pocketsphinx import * 
from sphinxbase.sphinxbase import * 

MODELDIR = "../../../model" 
DATADIR = "../../../test/data" 

config = Decoder.default_config() 
config.set_string('-hmm', path.join(MODELDIR, 'en-us/en-us')) 
config.set_string('-lm', path.join(MODELDIR, 'en-us/en-us.lm.bin')) 
config.set_string('-dict', path.join(MODELDIR, 'en-us/cmudict-en-us.dict')) 
config.set_string('-logfn', '/dev/null') 
decoder = Decoder(config) 

stream = open(path.join(DATADIR, 'goforward.raw'), 'rb') 
#stream = open('10001-90210-01803.wav', 'rb') 

in_speech_bf = False 
decoder.start_utt() 
while True: 
    buf = stream.read(1024) 
    if buf: 
     decoder.process_raw(buf, False, False) 
     if decoder.get_in_speech() != in_speech_bf: 
      in_speech_bf = decoder.get_in_speech() 
      if not in_speech_bf: 
       decoder.end_utt() 
       print 'Result:', decoder.hyp().hypstr 
       decoder.start_utt() 
    else: 
     break 
decoder.end_utt() 
+0

あなたはこれだけの各結果を連結 'secondsOfSilenceToDetect' –

答えて

-1
result = "" 

in_speech_bf = False 
decoder.start_utt() 
while True: 
    buf = stream.read(1024) 
    if buf: 
     decoder.process_raw(buf, False, False) 
     if decoder.get_in_speech() != in_speech_bf: 
      in_speech_bf = decoder.get_in_speech() 
      if not in_speech_bf: 
       decoder.end_utt() 
       result = result + decoder.hyp().hypstr 
       decoder.start_utt() 
    else: 
     break 
decoder.end_utt() 

return result 
+0

のための長い値を設定することができるかもしれません。たとえば、タグのすべてを取得します。 –

+0

result.replace( ''、 '') –

+0

ありがとうございますが、全体的な信頼スコアなどはまだ表示されません。なぜ結果が返ってくるのではなく、発話が途切れてしまうのですか? –

関連する問題