10 Replies Latest reply on Feb 21, 2016 11:52 AM by AlexT_Intel

    Enabling Jasper on Edison (http://jasperproject.github.io/)

    AlexT_Intel

      So this was a weekend project I wanted to try out - enabling that Jasper system based on voice recognition and text to speech on Edison (read more at their website). It allows you to create a system, which reacts to your voice commands, can reply using voice as well and you can add your own modules by writing them in Python. It's nice and really works (though the TTS sounds really creepy ) and can really surprise your friends if you teach it to do useful stuff.

       

      I've got that done (in the half-baked mode, i.e. without packing everything into nice opkg packages and so on, just compiling and directly installing) and just want to share that in case someone else goes after that - to save you quite some time in compiling and hunting down all the dependencies. I'm not personally interested in continuing further than that, but feel free to ask if you need any help.

       

      Just to make it clear, this is not a finished how-to, these are more like working notes, which will be useful if you're going to follow this way.

       

      By going to http://repo.opkg.net/edison/misc/jasper you'll find a tar.bz2 file with two dirs inside:

      1. home/local - that's what I used instead of the /usr/local (by creating a symlink to /home/local) when compiling & "make install"-ing the dependencies;
      2. home/root/jasper - that's where all the sources and compilation results are (which you can "make install" right away + Jasper scripts themselves (in home/root/jasper/jasper);

       

      Both take more space than default partitioning has for you on Edison's rootfs, so you'll either need to repartition yours, or do the symlinking stuff like I did. Or rebuild the dependencies into /home/something instead of /usr/local.

       

      On the Edison OS side, you'll naturally need sound in and out, which most probably means USB audio and that in turn means you'll need to install a kernel supporting it, see this blog post for instructions.

      Then you'll need to install the following packages: "alsa-utils libportaudio2 libasound2 bison espeak"

       

      As far as Python is concerned, you'll need to install some prerequisites using pip (install it using standard get-pip.py, works fine):

      pip install -r /home/root/jasper/jasper/client/requirements.txt

      pip install --allow-external pyaudio --allow-unverified pyaudio pyaudio

      There're also a couple of modules located in that tar.bz2 file, which are under home/local/lib/python2.7 - you need to either move them to /usr/lib/python2.7, or add that location into your PYTHONPATH.

       

      And finally, there's a set of exports to add into your ~/.profile file on the board, to make sure Jasper finds its pieces:

      root@edison1:~# cat ~/.profile

      export LD_LIBRARY_PATH="/home/local/lib"

      export PATH="$PATH:/home/local/bin:/home/local/lib"

      export PKG_CONFIG_PATH="/home/local/lib/pkgconfig"

      export JASPER_HOME="/home/root/jasper"

      export PYTHONDONTWRITEBYTECODE="1"

        • 1. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
          a_Monteiro

          Hi,

           

          I tried to install pyAudio but there is an error (How can i fix this ?):

           

          root@edison:/usr/lib/python2.7/site-packages# pip install --allow-external pyaudio --allow-unverified pyaudio pyaudio

          Collecting pyaudio

            pyaudio is potentially insecure and unverifiable.

            Downloading http://people.csail.mit.edu/hubert/pyaudio/packages/pyaudio-0.2.8.tar.gz (235kB)

              100% |################################| 237kB 952kB/s

          Installing collected packages: pyaudio

            Running setup.py install for pyaudio

              Complete output from command /home/root/miniconda/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-Nc8ohv/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qXycV5-record/install-record.txt --single-version-externally-managed --compile:

              running install

              running build

              running build_py

              creating build

              creating build/lib.linux-i686-2.7

              copying src/pyaudio.py -> build/lib.linux-i686-2.7

              running build_ext

              building '_portaudio' extension

              creating build/temp.linux-i686-2.7

              creating build/temp.linux-i686-2.7/src

              gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/root/miniconda/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-i686-2.7/src/_portaudiomodule.o

              In file included from /home/root/miniconda/include/python2.7/Python.h:8:0,

                               from src/_portaudiomodule.c:28:

              /home/root/miniconda/include/python2.7/pyconfig.h:1182:0: warning: "_POSIX_C_SOURCE" redefined [enabled by default]

               #define _POSIX_C_SOURCE 200112L

               ^

              In file included from /usr/include/stdio.h:27:0,

                               from src/_portaudiomodule.c:27:

              /usr/include/features.h:230:0: note: this is the location of the previous definition

               # define _POSIX_C_SOURCE 200809L

               ^

              src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory

               #include "portaudio.h"

                                     ^

              compilation terminated.

              error: command 'gcc' failed with exit status 1

           

           

              ----------------------------------------

              Command "/home/root/miniconda/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-Nc8ohv/pyaudio/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-qXycV5-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-Nc8ohv/pyaudio

          • 2. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
            franky.hsieh

            Hi,

             

            PyAudio depends on libportaudio-dev. So you need to install libportaudio-dev to have the header file to compile pyaudio. Here is the command to do it:

            opkg install libportaudio-dev

            And libportaudio-dev needs jack-dev. Unfortunately, the dependencies of jack-dev (and libjack) seems has some problem so you can not install it without problem. I tried and failed to install jack-dev on Release 2.1 Yocto* complete image. You might get error message like:

             

            Collected errors:

            * satisfy_dependencies_for: Cannot satisfy the following dependencies for jack-dev:

            * jack (= 0.121.0-r0) *

            * opkg_install_cmd: Cannot install package jack-dev.

             

            Here is how I resolve it. I installed libjack and then force to install jack-dev as a workaround. And I think --force-depends should works, either.

            opkg install libjack

            opkg install --nodeps jack-dev

            opkg install libportaudio-dev

            pip install pyaudio

             

            Now I'm happy with PyAudio.

             

            Hope this helps.

            • 3. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
              a_Monteiro

              Hi franky.hsieh

              I tried to install what you mentioned and I received the following errors, Did you come across this  :

              Collected errors:

              * pkg_get_installed_files: Failed to open //var/lib/opkg/info/systemd-zsh.list: No such file or directory.

              This happens everytime I try to use opkg to install anything ...

               

              thanks

              • 4. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
                seankim811

                Hi Alex,

                 

                I tried to follow up your recipte for porting(install) Jasper on Intel Edison. The last Edison image already has all ALSA utilities and don't need to take care of Audio In/Out.

                I checked arecord & aplay with wav file using Zabra USB headset. Then next step, I downloaded your tar.bz2 into my local folder then extract it. Now, what's next step ? Do I need to make & install some package of Jasper from the extracted folder ? I cannot make any start makefile for make & install. Please let me have step by step guide as a beginner point of view. Thanks a lot.

                • 5. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
                  seankim811

                  I copied /home/local to /usr/local then follow your steps of Jasper and pyaudio. First, I faced the following which is solved by setting "PYTHONPATH" to 'PYTHONPATH=/usr/local/lib/python2.7/site-packages/'.

                  ===========================================================

                  JASPER The Talking Computer

                  Copyright 2013 Shubhro Saha & Charlie Marsh

                  ===========================================================

                  DEBUG:client.diagnose:Checking network connection to server 'www.google.com'...

                  DEBUG:client.diagnose:Network connection working

                  DEBUG:__main__:Trying to read config file: '/home/root/.jasper/profile.yml'

                  DEBUG:client.diagnose:Checking python import 'pocketsphinx'...

                  DEBUG:client.diagnose:Python import 'pocketsphinx' not found

                  Traceback (most recent call last):

                    File "./jasper.py", line 138, in <module>

                      logger.exception("Error occured!", exc_info=True)

                  TypeError: exception() got an unexpected keyword argument 'exc_info'

                   

                  Now, I can hear the creepy voice of Jasper. Thanks a lot your contribution. :-)

                  • 6. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
                    AlexT_Intel

                    You are welcome and thanks for reporting back, I'm glad you have it working. Yeah, it was a while ago, nowadays you don't need to reinstall kernel (USB audio drivers are already there).

                    • 7. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
                      Alvin.Lau

                      Hi, Alex

                      I'm trying to enable Jasper on Edison, too.

                      I get blocked when i build mitlm-0.4.1. Add gfortran version: Package gfortran (4.9.1-r0) installed. Did you meet the same issue? Or if you can give me some hint to resolve this?  I'm green hands on Edison. Thanks.

                      Error:

                      checking for gcc option to accept ISO C89... none needed

                      checking for style of include used by make... GNU

                      checking dependency style of gcc... gcc3

                      checking for g++... g++

                      checking whether we are using the GNU C++ compiler... yes

                      checking whether g++ accepts -g... yes

                      checking dependency style of g++... gcc3

                      checking for g77... no

                      checking for xlf... no

                      checking for f77... no

                      checking for frt... no

                      checking for pgf77... no

                      checking for cf77... no

                      checking for fort77... no

                      checking for fl32... no

                      checking for af77... no

                      checking for xlf90... no

                      checking for f90... no

                      checking for pgf90... no

                      checking for pghpf... no

                      checking for epcf90... no

                      checking for gfortran... no

                      checking for g95... no

                      checking for xlf95... no

                      checking for f95... no

                      checking for fort... no

                      checking for ifort... no

                      checking for ifc... no

                      checking for efc... no

                      checking for pgfortran... no

                      checking for pgf95... no

                      checking for lf95... no

                      checking for ftn... no

                      checking for nagfor... no

                      checking whether we are using the GNU Fortran 77 compiler... no

                      checking whether  accepts -g... no

                      checking build system type... i686-pc-linux-gnu

                      checking host system type... i686-pc-linux-gnu

                      checking how to get verbose linking output from ... configure: WARNING: compilation failed

                       

                       

                      checking for Fortran 77 libraries of ...

                      checking for dummy main to link with Fortran 77 libraries... none

                      checking for Fortran 77 name-mangling scheme... configure: error: in `/media/sdcard/Download/mitlm-0.4.1':

                      configure: error: cannot compile a simple Fortran program

                      See `config.log' for more details

                      • 8. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
                        Alvin.Lau

                        Hi, Alex

                        I get blocked when i try to enable jasper on Edison. Did you meet this issue?

                        Error log

                        root@edison:~/jasper# ./jasper/jasper.py --debug

                        /usr/lib/python2.7/site-packages/pip/util.py:7: UserWarning: Module argparse was already imported from /usr/lib/python2.7/argparse.pyc, but /usr/lib/python2.7/site-packages is being added to sys.path

                          import pkg_resources

                        ===========================================================

                        JASPER The Talking Computer

                        Copyright 2013 Shubhro Saha & Charlie Marsh

                        ===========================================================

                        DEBUG:client.diagnose:Checking network connection to server 'www.baidu.com'...

                        DEBUG:client.diagnose:Network connection working

                        DEBUG:__main__:Trying to read config file: '/home/root/.jasper/profile.yml'

                        DEBUG:client.diagnose:Checking python import 'pocketsphinx'...

                        DEBUG:client.diagnose:Python module 'pocketsphinx' found: '/home/local/lib/python2.7/site-packages/pocketsphinx.so'

                        WARNING:root:tts_engine not specified in profile, defaulting to 'espeak-tts'

                        DEBUG:client.diagnose:Checking executable 'aplay'...

                        DEBUG:client.diagnose:Executable 'aplay' found: '/usr/bin/aplay'

                        DEBUG:client.diagnose:Checking executable 'espeak'...

                        DEBUG:client.diagnose:Executable 'espeak' found: '/usr/bin/espeak'

                        DEBUG:client.vocabcompiler:compiled_revision is 'bb74ae36d130ef20de710e3a77b43424b8fa774f'

                        Exception AttributeError: "'PocketSphinxSTT' object has no attribute '_logfile'" in <bound method PocketSphinxSTT.__del__ of <client.stt.PocketSphinxSTT object at 0x9307e8c>> ignored

                        Traceback (most recent call last):

                          File "./jasper/jasper.py", line 138, in <module>

                            logger.exception("Error occured!", exc_info=True)

                        TypeError: exception() got an unexpected keyword argument 'exc_info'

                        • 9. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
                          Alvin.Lau

                          I pull the latest Jasper client. And rename some lib in local folder like

                          libcmuclmtk.so.0.0.0 -> libcmuclmtk.so.0

                           

                          then, I can use Jasper to talk. Though it sounds weird, and bad voice recognition

                          • 10. Re: Enabling Jasper on Edison (http://jasperproject.github.io/)
                            AlexT_Intel

                            Yeah, it was a while ago, so things may have changed and all libraries might need an update. Glad you have it solved by now.