Python module issues

Hey there! I feel silly for having to post this, but not used to having basic examples just refusing to work for me no matter what I try! I’m pretty sure I’m doing something silly, but really need some advice on what it is I’m doing wrong!

Hello world example: https://github.com/spokestack/python-hello-world
Installed as venv and have used the provided requirements.txt (which uses spokestack 0.0.2). When I try to run, it starts fine, but when the wakeword ‘spokestack’ is detected I get:

python app.py                  
RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd
ImportError: numpy.core.multiarray failed to import

What am I doing wrong?

For the first error, that’s related to a mismatch in numpy versions. The numpy the version should be 1.19.2. There is a weird interaction with Cython and numpy around 1.20.0, but TensorFlow still uses 1.19.2.

For the second part, try it with pip install spokestack==0.0.22. The profiles were added a little later so it sounds like they are not in the version you are using.

Hey Will! I’ve adjusted requirements.txt to use 0.0.22, but I still get the error. Here are the versions I’m running across the dependancies:

Requirement already satisfied: wheel in ./bobpi1/lib/python3.9/site-packages (from -r requirements.txt (line 1)) (0.37.0)
Requirement already satisfied: spokestack==0.0.22 in ./bobpi1/lib/python3.9/site-packages (from -r requirements.txt (line 2)) (0.0.22)
Requirement already satisfied: pyaudio in ./bobpi1/lib/python3.9/site-packages (from -r requirements.txt (line 3)) (0.2.11)
Requirement already satisfied: streamp3 in ./bobpi1/lib/python3.9/site-packages (from -r requirements.txt (line 4)) (0.1.7)
Requirement already satisfied: numpy==1.19.2 in ./bobpi1/lib/python3.9/site-packages (from -r requirements.txt (line 5)) (1.19.2)
Requirement already satisfied: cython==0.29.22 in ./bobpi1/lib/python3.9/site-packages (from -r requirements.txt (line 6)) (0.29.22)

Any further ideas?

Let’s try forcing everything to reinstall.

pip install --force-reinstall -r requirements.txt

No luck. Same error. I did a no-deps install with the following versions to see if there was any difference:

wheel
spokestack==0.0.22
pyaudio
streamp3
numpy==1.21.3
cython==0.29.24

I no longer get the error, but it just drops me out at the console after running app.py. Out of interest, is the example also supposed to have a pipeline.run or pipeline.start in there somewhere?

You are absolutely right. There should be a call to pipeline.run() at the bottom of main().

Thanks Will, saw the update in the repo! FYI - I’m still not able to get this example code working:

  • with the current requirements.txt I get the module compile error
  • when I use the later version of numpy (1.21.3), ignoring dependancies, I don’t get any errors but spokestack won’t activate on the activate word “spokestack”

Separately, I was able to get the minecraft skill example working - it activates and recognises intent, however there I found an issue too in the imports section

It refers to this:
from spokestack.asr.speech_recognizer import CloudSpeechRecognizer

But should actually be:
from spokestack.asr.spokestack.speech_recognizer import CloudSpeechRecognizer

EDIT: The “issue” above relates to some change between spokestack 0.0.22 and 0.0.3 (which minecraft uses) - the requirements.txt in the minecraft example looks like a bit of a mess - I didn’t even bother trying to use that, I just used the requirements.txt with no-deps that I posted in here, and it works.

Either way I’m glad that I’ve got one example working, but a bit disappointed that I wasn’t able to get the other basic examples working - I might try again on my RaspberryPi instead of my Mac and see if I get different results.