NameError message with "Spectral Noise Removal

Asked 2 years ago, Updated 2 years ago, 37 views

Spectral denoising to eliminate noise
https://www.ai-shift.co.jp/techblog/1305

Looking at the above site, I would like to perform noise removal on the Jupiter Notebook.
The error message appears in the 12th line of the second program:

 noise_stft=_stft( noise_clip, n_ft, hop_length, win_length)

error:

NameError: name 'noise_clip' is not defined

No matter what part of the site you look at, noise_clip is only on the 12th line.
Please let me know if you know how to solve it.

python python3

2022-09-30 19:42

1 Answers

Refer to article
Spectral noise removal to eliminate noise
Information about library methods to invoke
librosa.stft

Parameters:y:np.ndarray [shape=(n,)], real-validated
        input signal

From the above article, noise_clip is passed by the y parameter (the input signal of the numpy array) using the library method librosa.stft().

In the article below, the input signal is waveform data such as .wav, and in the librosa library, the load method reads the .wav file, etc., or created by numpy, etc.
librosa
that may be very useful for signal processing and music analysis Read audio in Python's voice processing library [LibROSA] スペ Spectrogram conversion and display 位相 Estimate phase and restore audio
Methods for sound noise reduction
librosa.load

In addition to noise_clip, audio_clip is also required according to the reference article, so audio_clip seems to be the original sound source data and noise_clip is the original sound source data.

"Original sound source" is probably the first 12-second audio data in the reference article, and "Original sound source noise" is the third 10-second audio data.

Therefore, it would be good to download each data from the article as a .wav file and read the data as follows before the line in question.

import librosa
audio_clip, rate=librosa.load('Original Sound Source.wav')
noise_clip, rate = librosa.load ('noise portion of original sound source .wav')

import scipy.signal####Things that are not directly related to the above but are required after the reference article

Regardless of whether or not the results are correct, you can connect the sources of the reference article and insert the above parts in the appropriate position so that they can be executed without errors.

Alternatively, noise_clip may be the result of processing audio_clip with the first source envelope() of the referenced article.
For example:

audio_clip, rate=librosa.load('original sound source.wav')
noise_mask, noise_clip = envelope (audio_clip, rate, threshold for determining some noise)

#### In addition, you may need to do something about it after this.


2022-09-30 19:42

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.