我正在使用 sphinx 将音频转换为文本,但我找不到如何访问每个单词的置信度得分
我可以访问转录输出,但无法获得模型背后的估计概率。这感觉很基本,但我找不到合适的文档。我应该在下面添加什么?
test = sr.AudioFile(audio_file)
Recon = sr.Recognizer()
with test as source:
test_audio = Recon.record(source)
text = Recon.recognize_sphinx(test_audio,language = 'en-US')```
请您参考如下方法:
当前版本的语音识别未返回置信度结果。如果您查看 implementation :
def recognize_sphinx(...):
...
# return results
hypothesis = decoder.hyp()
if hypothesis is not None: return hypothesis.hypstr
raise UnknownValueError() # no transcriptions available
您会看到仅返回文本结果 (hypothesis.hypstr),而置信度在 hypothesis.prob 中。一个快速的解决方法是复制粘贴 entire method单独安装 pocketsphinx 后:
pip install pocketsphinx
