Open antondim opened 4 years ago
Hello,
I did kind of a hack, but it seems to work:
reduce_noise
against it. Something like:
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 self.reduce_audio_noise(_bytes)
.
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: