Search code examples
pythonpocketsphinxubuntu-17.04

How to fix: ImportError: cannot import name LiveSpeech?


I am trying to use LiveSpeech with my model and dictionary which I have trained:

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

But I am getting the following error:

Traceback (most recent call last): File "./main.py", line 3, in from pocketsphinx import LiveSpeech ImportError: cannot import name LiveSpeech

NOTE: I have successfully installed pocketsphinx from CMU Sphinx


Solution

  • I had an old version of pocketsphinx. Make sure to have the latest installed.

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