Exemplo n.º 1
0
 def remove_noise(self):
     y,sr = librosa.load("test.wav")
     noise_len = 2 # seconds
     noise = band_limited_noise(min_freq=2000, max_freq = 12000, samples=len(y), samplerate=sr)*10
     noise_clip = noise[:sr*noise_len]
     noise_reduced = nr.reduce_noise(audio_clip=y, noise_clip=noise_clip, prop_decrease=1.0, verbose=False)
     sf.write('test.wav', noise_reduced, sr)
     self.predict_lbl['text'] = 'Đã remove noise'
Exemplo n.º 2
0
def add_noise(audio_clip, rate):
    noise_len = 3
    noise = band_limited_noise(
        4000,
        12000,
        len(audio_clip),
        rate
    ) * 10
    noise_clip = noise[:rate * noise_len]
    return audio_clip + noise, noise_clip
Exemplo n.º 3
0
def test_reduce_generated_noise_stationary_without_noise_clip():
    # load data
    wav_loc = "assets/fish.wav"
    rate, data = wavfile.read(wav_loc)

    # add noise
    noise_len = 2  # seconds
    noise = (band_limited_noise(
        min_freq=2000, max_freq=12000, samples=len(data), samplerate=rate) *
             10)
    audio_clip_band_limited = data + noise
    return nr.reduce_noise(y=audio_clip_band_limited, sr=rate, stationary=True)
Exemplo n.º 4
0
def test_reduce_generated_noise():
    # load data
    wav_loc = "assets/fish.wav"
    rate, data = wavfile.read(wav_loc)
    data = data / 32768.
    # add noise
    noise_len = 2  # seconds
    noise = band_limited_noise(
        min_freq=2000, max_freq=12000, samples=len(data), samplerate=rate) * 10
    noise_clip = noise[:rate * noise_len]
    audio_clip_band_limited = data + noise
    return nr.reduce_noise(audio_clip=audio_clip_band_limited,
                           noise_clip=noise_clip,
                           verbose=True)
Exemplo n.º 5
0
def test_reduce_generated_noise():
    # load data
    wav_loc = "assets/coffe-1_2020-03-08_170854361.wav"
    rate, data = wavfile.read(wav_loc)
    data = int16_to_float32(data)
    # add noise
    noise_len = 2  # seconds
    noise = (band_limited_noise(
        min_freq=2000, max_freq=12000, samples=len(data), samplerate=rate) *
             10)
    noise_clip = noise[:rate * noise_len]
    audio_clip_band_limited = data + noise
    return nr.reduce_noise(audio_clip=audio_clip_band_limited,
                           noise_clip=noise_clip,
                           verbose=True)
Exemplo n.º 6
0
def test_reduce_generated_noise_batches():
    # load data
    wav_loc = "assets/fish.wav"
    rate, data = wavfile.read(wav_loc)

    # add noise
    noise_len = 2  # seconds
    noise = (band_limited_noise(
        min_freq=2000, max_freq=12000, samples=len(data), samplerate=rate) *
             10)
    noise_clip = noise[:rate * noise_len]
    audio_clip_band_limited = data + noise
    return nr.reduce_noise(y=audio_clip_band_limited,
                           sr=rate,
                           stationary=False,
                           chunk_size=30000)
Exemplo n.º 7
0
import numpy as np
import io

#ucitavanje zvuka
wav_loc = "C:/Users/Djordje/Desktop/download.wav"
rate, data = wavfile.read(wav_loc)
data = data / 32768

IPython.display.Audio(data=data, rate=rate)

fig, ax = plt.subplots(figsize=(20, 3))
ax.plot(data)

#dodavanje suma
noise_len = 2  # sekunde
noise = band_limited_noise(
    min_freq=2000, max_freq=12000, samples=len(data), samplerate=rate) * 10
noise_clip = noise[:rate * noise_len]
audio_clip_band_limited = data + noise

fig, ax = plt.subplots(figsize=(20, 3))
ax.plot(audio_clip_band_limited)

IPython.display.Audio(data=audio_clip_band_limited, rate=rate)

#uklanjanje suma
noise_reduced = nr.reduce_noise(audio_clip=audio_clip_band_limited,
                                noise_clip=noise_clip,
                                prop_decrease=1.0,
                                verbose=True)

#zvuk posle uklonjenog suma