如何解决:导入错误:无法导入名称 LiveSpeech?

问题描述

我正在尝试将 LiveSpeech 与我训练过的模型和字典一起使用:

#!/usr/bin/env python

from pocketsphinx import LiveSpeech

hmm = '/home/ridwan/sphinx/other1/output/other1.ci_cont' #folder of the acoustic model
lm = '/home/ridwan/sphinx/other1/output/other1.lm.DMP' #language model
dict = '/home/ridwan/sphinx/other1/output/other1.dic' #the phonetic dictionary

recognizer = LiveSpeech (verbose = False,sampling_rate = 16000,buffer_size = 2048,no_search = False,full_utt = False,hmm = hmm,lm = lm,dic = dict)

for phrase in recognizer:
    print (phrase)

但我收到以下错误

回溯(最近一次调用最后一次): 文件“./main.py”,第 3 行,在 从口袋狮身人面像导入 LiveSpeech 导入错误:无法导入名称 LiveSpeech

注意:我已经从 CMU Sphinx

成功安装了 Pocketsphinx

解决方法

我有一个旧版本的口袋狮身人面像。 确保安装了 latest

# Make sure we have up-to-date versions of pip,setuptools and wheel:
$ pip install --upgrade pip setuptools wheel

$ pip install --upgrade pocketsphinx