4

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/

허민선
  • 57
  • 1
  • 8
  • Possible duplicate of [Python pocketsphinx RequestError: missing PocketSphinx module: ensure that PocketSphinx is set up correctly](https://stackoverflow.com/questions/36523705/python-pocketsphinx-requesterror-missing-pocketsphinx-module-ensure-that-pocke) – Nikolay Shmyrev Jul 16 '17 at 09:08
  • it said "Requirement already satisfied: pocketsphinx in c:\python34\lib\site-packages" , or where i can find pocketsphinx package?, i'm running on windows – 허민선 Jul 25 '17 at 08:37
  • 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 Jul 25 '17 at 13:20
  • 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?, – 허민선 Jul 25 '17 at 15:17
  • swig is available on http://swig.org – Nikolay Shmyrev Jul 25 '17 at 15:18

1 Answers1

1

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
hobs
  • 18,473
  • 10
  • 83
  • 106