Ella Bryant
Ella Bryant

Reputation: 11

How to call the module pocketshinx within the module pocketsphinx for python?

So I'm trying to use a method in the pocketsphinx.py within the pocketsphinx module folder, but it gives me an error of:

ModuleNotFoundError: No module named 'pocketsphinx.pocketsphinx'; 'pocketsphinx' is not a package

I don't know what is going on because it works fine doing the same thing for sphinxbase. And 'import pocketsphinx' works, but doesn't input the exact method I need call decoder_default_config. Here is the code:

import pyaudio as py
from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *
import glob
import os, sys
model=(r'C:\Users\ellag\AppData\Local\Programs\Python\Python36\Lib\site-packages\pocketsphinx\model')
config = Decoder_default_config()
config.set_string('-hmm', os.path.join(model, 'en-us\en-us'))
config.set_string('-dict', os.path.join(model, 'en-us\cmuict-en-us.dict'))
config.set_string('-kws', os.path.join(model, 'kws_file'))
decoder = Decoder(config)
p = py.PyAudio()
stream = p.open(format=py.paInt16,channels=1,rate=16000,input=True)
stream.start_stream()
While True:
    buf=stream.read(1024)
    Decoder.process_raw(buf, False, False)
    if Decoder.hyp() != None:
        print(seg.word, seg.prob)
        letter=seg.word()

Upvotes: 1

Views: 1132

Answers (2)

krazatchu
krazatchu

Reputation: 1

This worked for me:

sudo apt-get install python3-pocketsphinx

Upvotes: 0

Nikhil Saji Thomas
Nikhil Saji Thomas

Reputation: 11

Try installing on terminal using:

sudo apt-get install pocketsphinx

Upvotes: 1

Related Questions