nerdaxic / glados-voice-assistant

DIY Voice Assistant based on the GLaDOS character from Portal video game series. Works with home assistant!
https://www.henrirantanen.fi/2022/02/10/glados-voice-assistant-with-custom-text-to-speech/?utm_source=github.com&utm_medium=social&utm_campaign=post&utm_content=DIY+GLaDOS+Voice+Assistant+with+Python+and+Raspberry+Pi
Other
279 stars 23 forks source link

Respeaker setting not honored #17

Closed salleq closed 2 years ago

salleq commented 2 years ago

In glados_respeaker.py:

    if "name 'pixel_ring' is not defined" in str(e):
        print("\nERROR: ReSpeaker is probably not connected?")
        #if(os.getenv('RESPEAKER_CONNECTED')):
        #   exit();

If I uncomment the two lines that I have commented above, I get the error "ReSpeaker is probably not connected" even though in settings.env there is: RESPEAKER_CONNECTED = False

eternalliving commented 2 years ago

You just need to put the print after the if statement:

     if "name 'pixel_ring' is not defined" in str(e):
    if(os.getenv('RESPEAKER_CONNECTED')):
            exit();
        print("\nERROR: ReSpeaker is probably not connected?")
        exit();

or better yet:

     if "name 'pixel_ring' is not defined" in str(e) and os.getenv('RESPEAKER_CONNECTED'):
        print("\nERROR: ReSpeaker is probably not connected?")
        exit();
eternalliving commented 2 years ago

Reviewing the code again it looks like respeaker_errors(e) shouldn't even be getting called if RESPEAKER_CONNECTED = False in your settings.env.... could it be getting called from another file?

eternalliving commented 2 years ago

if(os.getenv('RESPEAKER_CONNECTED')): is returning a string which will always = true. I've updated the file with the following for all the if's but this idea will need to be carried into the other files where the getenv's are treated as booleans. if(os.getenv('RESPEAKER_CONNECTED', 'False').lower() in ('true', '1', 't')):

salleq commented 2 years ago

This is something I had in mind (that it's always true) but didn't know how to change in Python.

nerdaxic commented 2 years ago

Thanks guys, confirmed to be working. Closing this dealio