【问题标题】:pocketsphinx: return long utterance as single resultpocketsphinx:将长话语作为单个结果返回
【发布时间】:2016-06-30 04:49:09
【问题描述】:

在分析大约 1 分钟长的声音文件时,pocketsphinx 会将文件分成多个结果。有没有办法更改代码以返回单个话语?我正在使用基于continuous_test.py 的代码。

#!/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()

【问题讨论】:

  • 您也许可以为secondsOfSilenceToDetect设置一个长值

标签: speech-recognition speech-to-text cmusphinx pocketsphinx


【解决方案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

【讨论】:

  • 这只是连接每个结果。例如,您仍然可以获得所有 标签。
  • result.replace('', '')
  • 谢谢,但它仍然无法让我看到整体置信度分数等。为什么以及如何分解话语,而不是返回一个结果?
猜你喜欢
  • 2013-12-29
  • 1970-01-01
  • 2023-03-24
  • 1970-01-01
  • 2017-02-17
  • 1970-01-01
  • 2015-02-05
  • 1970-01-01
  • 2018-06-29
相关资源
最近更新 更多