ERROR:root:Error occured! __init__() got an unexpected keywork argument 'hmm'

2,484 views
Skip to first unread message

Brent Hunter

unread,
Feb 15, 2015, 9:31:40 AM2/15/15
to jasper-sup...@googlegroups.com
Hello all,

I've installed Jasper onto a RPi2 successfully, and all is working well (kind of) when integrating with Google STT/TTS.

However, I wanted to use CMUSphinx/Pocketsphinx for offline recognition.  I've reconfigured Jasper profile, and now I get the following when executing jasper.py:


root@raspberrypi:/home/pi/jasper# ./jasper.py --debug

*******************************************************
*             JASPER - THE TALKING COMPUTER           *
* (c) 2015 Shubhro Saha, Charlie Marsh & Jan Holthuis *
*******************************************************
DEBUG
:client.diagnose:Checking network connection to server 'www.google.com'...
DEBUG
:client.diagnose:Network connection working
DEBUG
:__main__:Trying to read config file: '/root/.jasper/profile.yml'
DEBUG
:client.diagnose:Checking python import 'pocketsphinx'...
DEBUG
:client.diagnose:Python package 'pocketsphinx' found: '/usr/local/lib/python2.7/dist-packages/pocketsphinx/__init__.py'
DEBUG
:client.diagnose:Checking executable 'aplay'...
DEBUG
:client.diagnose:Executable 'aplay' found: '/usr/bin/aplay'
DEBUG
:client.diagnose:Checking executable 'text2wave'...
DEBUG
:client.diagnose:Executable 'text2wave' found: '/usr/bin/text2wave'
DEBUG
:client.diagnose:Checking executable 'festival'...
DEBUG
:client.diagnose:Executable 'festival' found: '/usr/bin/festival'
DEBUG
:client.tts:Executing festival --pipe
DEBUG
:client.vocabcompiler:compiled_revision is 'bb74ae36d130ef20de710e3a77b43424b8fa774f'
ERROR
:root:Error occured!
Traceback (most recent call last):
 
File "./jasper.py", line 138, in <module>
    app
= Jasper()
 
File "./jasper.py", line 101, in __init__
    stt_engine_class
.get_passive_instance(),
 
File "/home/pi/jasper/client/stt.py", line 48, in get_passive_instance
   
return cls.get_instance('keyword', phrases)
 
File "/home/pi/jasper/client/stt.py", line 42, in get_instance
    instance
= cls(**config)
 
File "/home/pi/jasper/client/stt.py", line 126, in __init__
   
**vocabulary.decoder_kwargs)
TypeError: __init__() got an unexpected keyword argument 'hmm'


Brent Hunter

unread,
Feb 15, 2015, 3:54:52 PM2/15/15
to jasper-sup...@googlegroups.com
After some time spent analysing the code in stt.py, I've discovered I needed to change the following code:

from:
 self._decoder = ps.Decoder(hmm=hmm_dir, logfn=self._logfile, **vocabulary.decoder_kwargs)
 


to:
        #self._decoder = ps.Decoder(logfn=self._logfile, hmm=hmm_dir, **vocabulary.decoder_kwargs)
 psConfig
= ps.Decoder.default_config()
 psConfig
.set_string('-hmm', hmm_dir)
 psConfig
.set_string('-lm', '/home/pi/lmfiles/cmusphinx-5.0-en-us.lm.dmp')
 psConfig
.set_string('-dict', '/home/pi/dictfiles/cmudict-0.7b.dict')
 
self._decoder = ps.Decoder(psConfig)

I still haven't got it working properly yet...  Is it because I'm using Pocketsphinx 5prealpha, instead of sphinx 0.8?

Brent Hunter

unread,
Feb 16, 2015, 12:20:15 PM2/16/15
to jasper-sup...@googlegroups.com
It's finally working.  I'm not sure why I had to change some code, but my guess is because I'm using 5prealpha (instead of pocketsphinx 0.8).

Ignore my post above. 

In the 'stt.py' file I removed the following line:
self._decoder = ps.Decoder(logfn=self._logfile, hmm=hmm_dir, **vocabulary.decoder_kwargs)


and replaced with this:
 psConfig = ps.Decoder.default_config()
 psConfig
.set_string('-hmm', hmm_dir)

 psConfig
.set_string('-lm', vocabulary.decoder_kwargs['lm'])
 psConfig
.set_string('-dict', vocabulary.decoder_kwargs['dict'])
 
self._decoder = ps.Decoder(psConfig)



Within the same 'stt.py' file I also had to change:
result = self._decoder.get_hyp()

to:
result = self._decoder.hyp()


Also:
transcribed = [result[0]]
was changed to:
transcribed = (result.hypstr, '')

transcribed is expecting to return a list of phrase/s, which is why I had to return a blank string along with the actual phrase to the transcribed variable.  I don't know Python that well, so if anyone can tell me why I had to do this would be great.






secret...@googlemail.com

unread,
Mar 19, 2015, 6:31:34 PM3/19/15
to jasper-sup...@googlegroups.com
Hi Brent

You post was most helpful, however I changed your last line to this:

        if result is None:

                transcribed
= ''

       
else:

                transcribed
= result.hypstr

Which seems to work wonderfully well. It seemed that in somecases result would end up as a NoneType which would cause things to error out. What this does is check to see if result has anything in it, and pass on either an empty string, or the object 'hypstr'

Wei

unread,
Sep 10, 2015, 4:01:11 AM9/10/15
to Jasper Support Forum
following your post then get this error: OSError: Can't find command 'phonetisaurus-g2p'! Please check if Phonetisaurus is installed and in your $PATH.

by the way, what is the change of profile.yml?

Jitendra

unread,
Sep 10, 2015, 5:45:06 AM9/10/15
to Jasper Support Forum
Hello Wei, Compile and install Sphinxbase/Pocketsphinx from source.


Installing Sphinxbase/Pocketsphinx


DONT DO THIS

First, you need to install Pocketsphinx. If you’re using Debian Sid (unstable) or Jessie (testing), you can just do:

sudo apt-get update
sudo apt-get install pocketsphinx

FOLLOW THIS

If you’re not using Debian Sid/Jessie, you need to compile and install them from source:

wget http://downloads.sourceforge.net/project/cmusphinx/sphinxbase/0.8/sphinxbase-0.8.tar.gz
tar -zxvf sphinxbase-0.8.tar.gz
cd ~/sphinxbase-0.8/
./configure --enable-fixed
make
sudo make install
wget http://downloads.sourceforge.net/project/cmusphinx/pocketsphinx/0.8/pocketsphinx-0.8.tar.gz
tar -zxvf pocketsphinx-0.8.tar.gz
cd ~/pocketsphinx-0.8/
./configure
make
sudo make install

Wei

unread,
Sep 10, 2015, 10:47:13 AM9/10/15
to Jasper Support Forum
Hi Jitendra,
I have installed pocketsphinx 0.5 and it works ok, this is business between Jasper and sphinx, i just don't know the configuration of it. And i didn't install openfst and other dependences. Is that ok?

Jitendra

unread,
Sep 10, 2015, 12:13:29 PM9/10/15
to Jasper Support Forum
Why you are using old version of pocketsphinx ? There is no harm in using pocketsphinx 0.8. with Jasper also follows the following step

Installing Phonetisaurus, m2m-aligner and MITLM

To use the Pocketsphinx STT engine, you also need to install MIT Language Modeling Toolkit, m2m-aligner and Phonetisaurus (and thus OpenFST).


DONT DO THIS

On Debian, you can install these from the experimental repository:

sudo su -c "echo 'deb http://ftp.debian.org/debian experimental main contrib non-free' > /etc/apt/sources.list.d/experimental.list"
sudo apt-get update
sudo apt-get -t experimental install phonetisaurus m2m-aligner mitlm

FOLLOW BELOW STEPS

If you’re not using Debian, perform these steps:


Wei

unread,
Sep 10, 2015, 3:50:53 PM9/10/15
to Jasper Support Forum
I have try to install openfst for several times, and compiling always stuck, someone said we need modify memory switch of raspberry pi, I didn't try that, I don't know if it will work.

Jitendra

unread,
Sep 11, 2015, 3:03:13 AM9/11/15
to Jasper Support Forum
Oh yes that the problem with Swap space.

Increase the swap space before compilation and then compile openfst and
after succesfull compilation remove swap file and free the memory

see below set of commands

To resize swap space:

sudo nano /etc/dphys-swapfile

CONF_SWAPSIZE=250

 

sudo dphys-swapfile setup

sudo dphys-swapfile  swapon

ls -l /var/swap

sudo apt-get --purge clean

Free the Swap space 

sudo swapoff -a

sudo update-rc.d -f dphys-swapfile remove

sudo rm /var/swap

ls -l /var/swap

free -h



Wei

unread,
Sep 11, 2015, 9:41:27 PM9/11/15
to Jasper Support Forum
Jitendra, thanks for your help, finally openfst successfully installed, 
at last, I got the same error: __init__() got an unexpected keyword argument 'hmm'
I modify the stt.py follow this post, and Jasper can print what I said, but has no response of any command, even no beeps.
seems Jasper didn't execute the command.
I installed pocketsphinx 5 prealpha and also installed pocketsphinx 0.8, so I just get confused, which one is working now?
how to uninstall pocketsphinx 5 prealpha? maybe I should uninstall it and reinstall 0.8.


John Evans

unread,
Aug 25, 2017, 6:56:08 AM8/25/17
to Jasper Support Forum
These instructions also helped me as well as the ones below (or above) from secret. I followed all the instructions for arch linux but just couldn't get it to work. I'm still not quite there but at least I'm a step further.
Thanks 

Asuthosh C R

unread,
Jan 20, 2018, 7:13:30 AM1/20/18
to Jasper Support Forum
pi@raspberrypi:~$ python /home/pi/jasper/jasper.py
Traceback (most recent call last):
  File "/home/pi/jasper/jasper.py", line 13, in <module>
    from client import stt
  File "/home/pi/jasper/client/stt.py", line 125
    psConfig = ps.Decoder.default_config()
                                          ^
IndentationError: unindent does not match any outer indentation level

i have got this error after changing the code according to what to have posted.

pls help me to solve the issue.
Reply all
Reply to author
Forward
0 new messages