2

I have installed the google speech API on the Pepper robot through SSH following the official Google tutorial.

To test it I created a file speechTest.py, where I import the API as following:

from google.cloud import speech

This is working! So far so good. But the problem arises when I want to do the same within a Python box in Choregraphe; When I get an error saying:

[ERROR] behavior.box :createPythonModule:0
_Behavior__lastUploadedChoregrapheBehaviorbehavior_11325017632:/GoogleSTT_7:
User class evaluation failed with the error:
<class 'pkg_resources.DistributionNotFound'>
google-cloud-speech

I tried the solution raised in the community but without success. When I print sys.path from the Python in Choregraphe box I get:

[WARN ] behavior.box :onLoad:15 _Behavior__lastUploadedChoregrapheBehaviorbehavior_1811402208:/GoogleSTT_7: 
/usr/lib/python2.7/site-packages
/usr/lib
/home/nao/.local/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg
/usr/lib/python27.zip
/usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/home/nao/.local/lib/python2.7/site-packages
/usr/lib/python2.7/site-packages/PIL
/usr/lib/python2.7/site-packages/gst-0.10
/usr/lib/python2.7/site-packages/gtk-2.0
/usr/share/dialog/
/home/nao/.local/share/PackageManager/apps/dialog_lexicon/./
/home/nao/.local/share/PackageManager/apps/dialog_adjust_volume/dlg_adjust_volume/
/home/nao/.local/share/PackageManager/apps/dialog_adjust_volume/my_apps_topic/
/home/nao/.local/share/PackageManager/apps/dialog_applauncher/dlg_applauncher/
/home/nao/.local/share/PackageManager/apps/dialog_applauncher/dlg_suggest_app/
/home/nao/.local/share/PackageManager/apps/dialog_battery_capacity/dlg_battery_capacity/
/home/nao/.local/share/PackageManager/apps/dialog_battery_level/dlg_battery_level/
/home/nao/.local/share/PackageManager/apps/dialog_bleep_sounds/dlg_bleep_sounds/
/home/nao/.local/share/PackageManager/apps/dialog_can_you_repeat/dlg_can_you_repeat/
/home/nao/.local/share/PackageManager/apps/dialog_clock/dlg_clock/
/home/nao/.local/share/PackageManager/apps/dialog_engines/dlg_engines/
/home/nao/.local/share/PackageManager/apps/dialog_goodbye/dlg_goodbye/
/home/nao/.local/share/PackageManager/apps/dialog_hello/dlg_hello/
/home/nao/.local/share/PackageManager/apps/dialog_help/dlg_help/
/home/nao/.local/share/PackageManager/apps/dialog_how_are_you/dlg_how_are_you/
/home/nao/.local/share/PackageManager/apps/dialog_impossible_moves/dlg_impossible_moves/
/home/nao/.local/share/PackageManager/apps/dialog_internet_connection/dlg_internet_connection/
/home/nao/.local/share/PackageManager/apps/dialog_lexicon/skin_B2B/
/home/nao/.local/share/PackageManager/apps/dialog_lexicon/skin_tmp_tweak/
/home/nao/.local/share/PackageManager/apps/dialog_manage_events/dlg_manage_events/
/home/nao/.local/share/PackageManager/apps/dialog_move_arms/dlg_move_arms/
/home/nao/.local/share/PackageManager/apps/dialog_move_hands/dlg_move_hands/
/home/nao/.local/share/PackageManager/apps/dialog_move_head/dlg_move_head/
/home/nao/.local/share/PackageManager/apps/dialog_posture/dlg_posture_pepper/
/home/nao/.local/share/PackageManager/apps/dialog_posture/dlg_posture_nao/
/home/nao/.local/share/PackageManager/apps/dialog_reflex_engaged/dlg_reflex_engaged/
/home/nao/.local/share/PackageManager/apps/dialog_robot_characteristics/dlg_character/
/home/nao/.local/share/PackageManager/apps/dialog_robot_characteristics/dlg_personal_info/
/home/nao/.local/share/PackageManager/apps/dialog_robot_characteristics/dlg_humanoid/
/home/nao/.local/share/PackageManager/apps/dialog_robot_characteristics/dlg_interaction/
/home/nao/.local/share/PackageManager/apps/dialog_robot_origins/dlg_robot_origins/
/home/nao/.local/share/PackageManager/apps/dialog_robot_relationships/dlg_robot_relationships/
/home/nao/.local/share/PackageManager/apps/dialog_robots/dlg_robots/
/home/nao/.local/share/PackageManager/apps/dialog_robots/dlg_asimov/
/home/nao/.local/share/PackageManager/apps/dialog_robots/dlg_famous_robots/
/home/nao/.local/share/PackageManager/apps/dialog_say_something_else/dlg_say_something_else/
/home/nao/.local/share/PackageManager/apps/dialog_set_offset/dlg_set_offset/
/home/nao/.local/share/PackageManager/apps/dialog_shutdown/dlg_shutdown/
/home/nao/.local/share/PackageManager/apps/dialog_stop_talking/dlg_stop_talking/
/home/nao/.local/share/PackageManager/apps/dialog_store/dlg_ade/
/home/nao/.local/share/PackageManager/apps/dialog_switch_language/dlg_switch_language/
/home/nao/.local/share/PackageManager/apps/dialog_thank_you/dlg_thank_you/
/home/nao/.local/share/PackageManager/apps/dialog_touch/dlg_touch_head/
/home/nao/.local/share/PackageManager/apps/dialog_what_can_you_do/dlg_what_can_you_do/
/home/nao/.local/share/PackageManager/apps//dialog_reflex/reflex/
/home/nao/.local/lib/python2.7/site-packages/google/cloud/

Which would indicate that it should find the Google package. How can I solve this problem? I have no idea how I could import the Google Speech API into the Choregraphe project.

EDIT: when I output sys.path in the local Python file on the robot, I get this:

/var/persistent/home/nao
/home/nao/.local/lib/python2.7/site-packages/pip-9.0.1-py2.7.egg
/usr/lib/python27.zip
/usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
/home/nao/.local/lib/python2.7/site-packages
/usr/lib/python2.7/site-packages
/usr/lib/python2.7/site-packages/PIL
/usr/lib/python2.7/site-packages/gst-0.10
/usr/lib/python2.7/site-packages/gtk-2.0
moffeltje
  • 4,521
  • 4
  • 33
  • 57
  • So you mean it works from the python script in a shell command but not from chroregraphe ? 1. is it working from the shell command whatever the location from where you start the python interpreter. 2. could you tell us were you install the package, so we can check it's visible from sys.path 3. do you restart naoqi once after the package installation ? sometimes adding new folders in .local needs the naoqi interpreter to be reloaded... good luck... – Alexandre Mazel Jun 09 '17 at 09:22
  • Hi @AlexandreMazel, 1) Yes, I can execute the python script on different locations. 2) When I run ` pip show google-cloud-speech` I get `Location: /var/persistent/home/nao/.local/lib/python2.7/site-packages` 3) I have restarted Pepper several times without luck. I have added the output of `sys.path` from the local python file (which seems much shorter) in my question. – moffeltje Jun 15 '17 at 14:41

1 Answers1

2

I believe that the best way to use a python library in your project that is not installed by default on the robot is to add it inside your project. This way your always sure that your dependencies are install when your packages is installed on a robot. It might not be ideal but that the more reliable solution.

Erratum: Actually if you are writing a service in python inside your project (python file) you can ship your dependencies by putting them next to your python file. But behaviors cannot use them and you indeed need to install them.

But what you can do is write a service in python inside your project that use google APIs and inside your behavior.xar start the service, use it to do what you need and stop the service when exiting. (ideally your service could stop itself when the behavior stop)

G. Vallat
  • 56
  • 3