How to listen continously in python from microphone, for detection of wake word like google and alexa?

84 Views Asked by At

I am trying to make a voice assistant that will get activated only when I say a wake word just like Google Assistant or alexa or siri.

If I am using speech recognition library for this but the problem is that it cannot listen continuously after a certain period it stopsstartsrecognizing for a moment and start recognising, even if there is nothing said, but what I want is just exact like a google assistant or Siri,Ithe when we say then only it should get activated.

In this case i have to use Machine learning but how I dont know, Because I dont know machine learning

This is my code that i am using :

def listening_with_condition(self):
    self.rec = Recognizer()  # recongnising

    with Microphone() as source1:
        # self.rec.adjust_for_ambient_noise(source1, duration=0.5)
        # rec.pause_threshold = 1
        print("listening...")
        self.c.itemconfig(self._micro, image=self._microphone)
        audio = self.rec.listen(source1)
        try:
            print("Recognising...")
            self.c.itemconfig(self._micro, image=self._microphoneoff)
            get_text = self.rec.recognize_google(audio)
            self.main_text = get_text.lower()

            self.conditions(self.main_text)

        except sr.RequestError:
            self.printing_on_interface(
                "No internet connection found", "No internet connection found...")
        except sr.UnknownValueError:
            self.printing_on_interface("", "")

This is the function that I am using in the Assistant Code for taking the microphone input, this is not for wake word but If this can't listen continously, wake word program will also have the same problem.

How can i achieve that continuous listening from my microphone?

1

There are 1 best solutions below

0
Kathy Reid On

The Speech Recognition library is for speech recognition, not wake word spotting, keyword spotting or voice activity detection, which is what you're trying to do. You should investigate libraries like: