4
votes

i just following this >> steps << and works well,

now, how do i get started with python? i tried this code:

import speech_recognition as sr

# obtain audio from the microphone
r = sr.Recognizer()
with sr.Microphone() as source:
    print("Say something!")
    audio = r.listen(source)

# recognize speech using Sphinx
try:
    print("Sphinx thinks you said " + r.recognize_sphinx(audio))
except sr.UnknownValueError:
    print("Sphinx could not understand audio")
except sr.RequestError as e:
    print("Sphinx error; {0}".format(e))

and got an error:

Sphinx error; missing PocketSphinx module: ensure that PocketSphinx is set up correctly.

speech_recognition already installed, but i'm not sure with pocketsphinx and sphinxbase. everything i did just following: https://cmusphinx.github.io/wiki/tutorialpocketsphinx/

1
it said "Requirement already satisfied: pocketsphinx in c:\python34\lib\site-packages" , or where i can find pocketsphinx package?, i'm running on windows - 허민선
Most likely you are trying to run speech_recognition with python2 while you installed pocketsphinx for python3. You need to make sure you have just a single python version. - Nikolay Shmyrev
i'm sure it was running on python3 and installed for python3, there was some problem when i install pocketsphinx, i need something called swig for install pocketsphinx by pip, how can i get that swig?, - 허민선
swig is available on swig.org - Nikolay Shmyrev

1 Answers

1
votes

You need to pip install PocketSphinx which depends on the binary SWIG package. For Windows the SWIG instructions are in this SO answer.

For OSX there are additional requirements:

$ brew install cmu-pocketsphinx
$ brew install portaudio
$ brew install swig
$ pip install PocketSphinx