Here's an excerpt from an example in SpeechRecognition repo:
except sr.UnknownValueError: print("Google Speech Recognition could not understand audio")