bishoph / sopare

Real time sound pattern recognition in Python for Raspberry/Banana Pi.
Other
320 stars 87 forks source link

Still getting Random Results #62

Closed hankp46 closed 5 years ago

hankp46 commented 5 years ago

Hello

This is a follow on to issue #57

I thought the problem was resolved by removing plugin and having only 1 custom in plugin directory. But today when running Sopare right after startup I get the following, Without saying anything: pi@raspberrypi:~/Desktop/GoPIGo/Software/Python/python-speech-recognition-master/sopare $ ./sopare.py -l attempt to connect to server failed ('input', [u'back']) Robocar Moving backward Leaving backward ('input', [u'back', u'stop']) Robocar Moving backward Leaving backward ('input', [u'back']) Robocar Moving backward Leaving backward ('input', [u'back']) Robocar Moving backward Leaving backward ('input', [u'forward']) Robocar Moving Forward Almost like it is retrieving from some old input.

Also - while probably a coding problem on my part - the program will exit the function called properly if I have the 'stop()' command but if i remove this (see Forward() function it will not print or exit the function. Any help on this would be appreciated it. Thanks!

Here's the plugin:

!/usr/bin/env python

-- coding: utf-8 --

""" Copyright (C) 2015 - 2017 Martin Kauss (yo@bishoph.org)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ from gopigo import * import sys import time

def Forward(): print("Robocar Moving Forward") fwd() time.sleep(2)

stop()

print("Leaving Forward")

def Back(): print("Robocar Moving backward") bwd() time.sleep(2) stop() print("Leaving backward")

def Stop(): print("Robocar Stopping") stop() print("Leaving Stop")

def run(readable_results, data, rawbuf): if (len(readable_results) > 2 or len(readable_results) == 0): return print("input",readable_results) try: if ('forward' in readable_results): Forward() elif ('back' in readable_results): Back() elif ('stop' in readable_results): Stop()

except Exception as err:
    print (err)

I wrote this custom plugin as a beginning to a robot project i am working on. I am getting some strange results. It recognizes my words and prints correct results but sometimes also prints random results, almost like it remembered words from a previous session (see bottom for some printout) Is there a file or buffer I should be clearing prior to initiating (I'm a newbie)

!/usr/bin/env python

-- coding: utf-8 --

""" Copyright (C) 2015 - 2017 Martin Kauss (yo@bishoph.org)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """

def Forward(): print("Robocar Moving Forward")

def Back(): print("Robocar Moving backward")

def Stop(): print("Robocar Stopping")

def run(readable_results, data, rawbuf): if (len(readable_results) > 2 or len(readable_results) == 0): return try: if ('forward' in readable_results) : Forward() elif ('back' in readable_results) : Back() elif ('stop' in readable_results) : Stop()

except Exception as err:
    print (err)

Results: ./sopare.py -l [u'forward'] Robocar Moving Forward [] [u'forward'] Robocar Moving Forward [] [] [] [] [u'back'] Robocar Moving backward [u'back', u'back'] Robocar Moving backward [] [] [u'back'] Robocar Moving backward [] [] [] [] [] [u'stop'] Robocar Stopping [] [] [] [u'stop'] I never said stop. Plus why is it printing {u'stop'} or any command when my plugin does not have a print readable_results
statement?