-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Applying noise reduction on pyaudio stream #44
Comments
Hello, I did kind of a hack, but it seems to work:
def __init__(self, output_to_file=True):
self.vad = webrtcvad.Vad(int(self.vad_aggressiveness))
self.deepspeech_model = self.load_deepspeech_model()
self.noise_sample_data = self.load_noise_sample_data()
def reduce_audio_noise(self, data: bytes) -> bytes:
np_data = np.frombuffer(data, np.int16) / 1.0
reduced_noise_data = reduce_noise(audio_clip=np_data, noise_clip=self.noise_sample_data)
return reduced_noise_data.astype(np.int16).tobytes()
def load_noise_sample_data(self) -> np.ndarray:
path = os.path.join(os.path.dirname(__file__), "../../../assets/deepspeech/noise_sample.wav")
with wave.open(path, "rb") as wf:
frames = wf.getnframes()
return np.frombuffer(wf.readframes(frames), np.int16) / 1.0 I would just stream the bytes return from Of course, the noise sample is pretty limited because it only recognizes one pattern of noise. I hope that can help. |
Hello! I am also facing a similar issue on "fan spinning" artifacts when trying to apply noisereduce on real-time microphone input. Curious if people have figured out a walkaround? |
@yujie-tao I faced the same issue and found a workaround to reduce this effect. By streaming audio as chunks with overlap, I was able to reduce this effect significantly. One of the side-effects to this is increase in latency. |
Hello,
First of all, thank you for your great module.
I'm trying to apply real-time noise reduction on incoming audio stream
Settings on stream opening:
Settings on stream reading:
The problem that I'm facing is that a periodical "fan spinning" sound appears, after actively applying noise reduction (while loop), but this sound does not appear on a normal 5 second recording with noise reduction on the np.int16 array afterwards.
What is different is that in the first case (active-ish noise reduction), I append the sound data for each iteration,after noise reduction, whereas in the second case I record for 5 seconds and THEN apply the noise reduction on the whole set of data.
I'm uploading example wavs to give you a better perspective:
normal_case_wavs.zip
active_case_wavs.zip
P.S I noticed that by changing the number of frames I read from the stream buffer, the frequency of this sound changes too. Could this be some kind of edge case where this sound indicates the change of "Sound CHUNK" I am processing (appending to the list for future .wav write) ?
Crucial part of code is here:
The text was updated successfully, but these errors were encountered: