Kitt-AI / snowboy

Future versions with model training module will be maintained through a forked version here: https://github.com/seasalt-ai/snowboy
Other
3.11k stars 1k forks source link

TypeError: __init__() got an unexpected keyword argument 'model_str' #18

Closed tiny-tinker closed 8 years ago

tiny-tinker commented 8 years ago

After successfully building from source, I'm running the demo, but ran into this error:

pi@raspberrypi:~/Downloads/snowboy/examples/Python $ python demo.py ./resources/snowboy.umdl 
Traceback (most recent call last):
  File "demo.py", line 27, in <module>
    detector = snowboydecoder.HotwordDetector(model, sensitivity=0.5)
  File "/home/pi/Downloads/snowboy/examples/Python/snowboydecoder.py", line 91, in __init__
    resource_filename=resource, model_str=model_str)
TypeError: __init__() got an unexpected keyword argument 'model_str'

Lines 90s in snowboydecoder.py:

        self.detector = snowboydetect.SnowboyDetect(
            resource_filename=resource, model_str=model_str)        # 91
        self.detector.SetAudioGain(audio_gain)
        self.num_hotwords = self.detector.NumHotwords()

But looking at snowboydetect.py, the constructor takes a pointer, so I'm not sure what it is complaining about. My python skills aren't great.

class SnowboyDetect(_object):
    __swig_setmethods__ = {}
    __setattr__ = lambda self, name, value: _swig_setattr(self, SnowboyDetect, name, value)
    __swig_getmethods__ = {}
    __getattr__ = lambda self, name: _swig_getattr(self, SnowboyDetect, name)
    __repr__ = _swig_repr
    def __init__(self, *args): 
        this = _snowboydetect.new_SnowboyDetect(*args)
        try: self.this.append(this)
        except: self.this = this
chenguoguo commented 8 years ago

Could you try the swig installation commands I pasted here? I suspect it's an issue with swig.

chenguoguo commented 8 years ago

Closing this since the issue was resolved through https://github.com/Kitt-AI/snowboy/issues/17

richardfuchs commented 8 years ago

I also had the Error: TypeError: init() got an unexpected keyword argument 'model_str'

My Setup:

I fixed it running a modified version of the https://github.com/Kitt-AI/snowboy/issues/17#issuecomment-224766173 scipt:

#!/bin/bash

# SWIG is a tool to compile c++ code into Python.

echo "Installing SWIG"

if [ ! -e swig-3.0.7.tar.gz ]; then
  wget -T 10 -t 3 \
    http://prdownloads.sourceforge.net/swig/swig-3.0.7.tar.gz || exit 1;
fi

tar -xovzf swig-3.0.7.tar.gz || exit 1
ln -s swig-3.0.7 swig

cd swig

# We first have to install PCRE.
if [ ! -e pcre-8.37.tar.gz ]; then
  wget -T 10 -t 3 \
    https://sourceforge.net/projects/pcre/files/pcre/8.37/pcre-8.37.tar.gz || exit 1;
fi
Tools/pcre-build.sh

./configure --with-pic
make
sudo make install

cd ..

I also installed the needed programs/libs: https://github.com/Kitt-AI/snowboy#ubunturaspberry-pi and compiled snowboy myself (the pre-compiled/provided version had the above error) https://github.com/Kitt-AI/snowboy#compile-a-python-wrapper

chenguoguo commented 8 years ago

@richardfuchs could you give me the link of the pre-compiled version that doesn't work? I should fix that.

richardfuchs commented 8 years ago

@chenguoguo https://s3-us-west-2.amazonaws.com/snowboy/snowboy-releases/rpi-arm-raspbian-8.0-1.0.4.tar.bz2 (Referenced in https://snowboy.kitt.ai/docs in Downloads)