0

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

Ridwan
  • 214
  • 4
  • 17
  • 1
    This definitely isn't sufficient info to answer the question. How did you install the package? – user202729 Feb 24 '21 at 07:49
  • Besides you only need the import statement to reproduce the issue. [example] – user202729 Feb 24 '21 at 07:49
  • What makes you think pocketsphinx includes a class called LiveSpeech? I see no evidence of that. And the link you provided is about 10 years old. The current version is on GitHub. https://github.com/cmusphinx/pocketsphinx – Tim Roberts Feb 24 '21 at 08:05
  • @TimRoberts [Here](https://pypi.org/project/pocketsphinx/) you can find that they use LiveSpeech imported from pocketsphinx. – Ridwan Feb 24 '21 at 17:09
  • @user202729 I downloaded pocketsphinx and unzip it and then run `configure` and `make` and `sudo make install` in the package folder. – Ridwan Feb 24 '21 at 17:11
  • There are at least three different forks of pocketsphinx. The one you linked to is an old version that does not include LiveSpeech. If you uninstall that and do "pip install pocketsphinx", you should get you the bambocher fork that includes LiveSpeech. – Tim Roberts Feb 24 '21 at 19:47
  • Do I need to `configure`, `make`, `make install` again? – Ridwan Feb 24 '21 at 19:59
  • @TimRoberts I am still getting the same error after doing `sudo pip3 install pocketsphinx` – Ridwan Feb 25 '21 at 16:57
  • Did you uninstall the other one? It's possible you have both versions installed, one local, one system-wide. – Tim Roberts Feb 25 '21 at 19:22
  • How to uninstall the other one? I didn't install it from terminal? (I just new to Linux) – Ridwan Feb 25 '21 at 19:35

1 Answers1

0

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
Ridwan
  • 214
  • 4
  • 17