'Python SpeechRecognition Having Hard Time Detecting A Specific Word

I made a python program that works kind of like a voice assitant, I can tell it to play a spotify song and it will run gui automation code to find and play that song

right I'm trying to implement a pause function but the problem I'm facing is that it is having a hard time hearing the word Pause and it almost always detects it as Balls or Bars

Listen Function:

def listen(self):
    with self.mic as source:
        self.r.adjust_for_ambient_noise(source)
        text = self.r.listen(source)
    
    recognition_text = ""

    try:
        recognition_text = self.r.recognize_google(text)
    except sr.UnknownValueError:
        pass
    except sr.RequestError as er:
        pass

    if self.debug_recognition:
        print("Heared: " + recognition_text)

    return recognition_text.lower()

is there a way to get it to get a more accurate result or is there not fix for this problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source