0

I'm trying to build a chatbot application on my Pepper. To do this, I plan to use the Pepper Speech Recognition module first to detect the sentences and get the text.

Here's the link: https://github.com/JBramauer/pepperspeechrecognition

Actually, if I put the whole directory of the Speech Recognition module on Pepper, ssh to it and run module_speechrecognition.py and module_receiver.py on it at the same time, the robot does get the right text. But now, I want to use this module on Choregraphe so as to build an application in the end. So, I added the same directory in the project files in Choregraphe and added its path to sys.path to make it possible to import things from this directory. However, I have no idea what to do next. I tried to do "import module_speechrecognition" in a python box in Choregraphe but there was an error saying:

from google import Recognizer, UnknownValueError, RequestError

ImportError: cannot import name Recognizer

Yes, in module_speechrecogniton.py, other python files in the same directory are imported. I guess there should be some modifications in module_speechrecogniton.py. So, What can I do to run this module in Choregraphe just like what I did on Pepper using Putty?

Update: I added an empty __init__.py file in my directory and used

from pepperspeechrecognition_master import module_speechrecognition
module_speechrecognition.main()

but another error came up.

[ERROR] behavior.box :_safeCallOfUserMethod:125 _Behavior__lastUploadedChoregrapheBehaviorbehavior_11647009840:/Python Script_1: 
Traceback (most recent call last):  
File "/opt/aldebaran/lib/python2.7/site-packages/albehavior.py", line 115, in _safeCallOfUserMethod     func()   
File "<string>", line 16, in onInput_onStart   
File "/home/nao/.local/share/PackageManager/apps/.lastUploadedChoregrapheBehavior/behavior_1/../pepperspeechrecognition_master/module_speechrecognition.py", line 456, in main     (opts, args_) = parser.parse_args()   
File "/usr/lib/python2.7/optparse.py", line 1381, in parse_args     rargs = self._get_args(args)   
File "/usr/lib/python2.7/optparse.py", line 1363, in _get_args     
return sys.argv[1:] AttributeError: 'module' object has no attribute 'argv' 
  • You should use some parameters to call method of your module instead of receiving parameters from command line. It will make your module more explicit, standard and easier to reuse in the future, like module_speechrecognition.main( parameter1, parameter2). by the way main, is not an explicit method name... – Alexandre Mazel Aug 23 '19 at 19:38

1 Answers1

1

Try to create a file called __init__.py in the Models directory, so that python treats it as a module.

Check this other post: link

TVK
  • 1,042
  • 7
  • 21
  • I added an empty __init__.py file in my directory, but this doesn't solve the problem. Please take a look at my update above. – user10819593 Aug 23 '19 at 10:01