GRPC get function call when nothing is spoken

75 views Asked by At

I am using the GRPC demo provided by the AIY voice kit as a template for an assistant that uses custom commands. The AIY version I am using has a file structure set up for both vision and voice (but I am not using the vision part).

I want to test if the user does not say anything after pressing the button so that I can play a sound or give some other indication (such as changing the status light or saying "Sorry, I didn't catch that.") that whatever command that was spoken wasn't heard and that they need to press the button again before speaking.

I know there is a function that is called when there is no response in the assistant library and/or the cloudspeech library, but I want to use a function call with the GRPC, which does not use the Google Assistant API.

Any answers are greatly appreciated, but please try to keep it simple. I have a good understanding of python, but little to no experience with any of what the AIY does in the background.

1

There are 1 answers

0
John Locke On

Ok, I figured it out on my own. You can test if the variable text is None. None is not a string, it is , so it does not trigger any commands, it just ignores string testing statements.

if text is None:
        print('Sorry, I did not hear you.')

From there I can do a function call, play a sound, or have the tts say something.

I have to give credit to this question, because I saw the above code on that question and realized it was for when the voice recognition didn't hear anything. I tested it on my program and it works exactly as intended.