import speech_recognition as sr
def noice_fix(mic):
with mic as source:
sr.adjust_for_ambient_noise(source)
while True:
try:
audio = sr.listen(source, timeout=0.1)
# Check if audio loud enough
rms = audio.rms
if rms < 35:
continue # ignore audio if too quiet
except sr.WaitTimeoutError:
pass
except:
print("Error while recording audio")
Problems:
Cannot find reference 'adjust_for_ambient_noise' in '__init__.py'
Cannot find reference 'listen' in '__init__.py'
This is only part of the code, but the main point is that this function would let all incoming sound through, and ignore the sound below 35 decibels in real-time
I called speech_recognition as sr but the code doesn't see that, I guess. I tried to rename the function, and reinstall the library but it does not working yet.
source https://stackoverflow.com/questions/76212037/speech-recognition-python-3-11-2
Comments
Post a Comment