2
$\begingroup$

Have many audio files 1 minute long. Some of them are normal. Some of them are noise.

Here is a normal file:

enter image description here

This is a noise:

enter image description here

And this is noise too:

enter image description here

How do auto detect noise using python?

BTW: if you suggest any external console program which can do that it will be cool too.

$\endgroup$
  • $\begingroup$ It depends on what kind of signal you are looking for, and what kind of noise. I would suggest spectral flatness as a simple way to distinguish between them. Noise will have a flat spectrum, while interesting signals will not. $\endgroup$ – endolith Oct 31 '14 at 14:55
2
$\begingroup$

First, there are many ways to do your task. Depending on your background, some might be easier than others for you to understand and use.

If you are familiar with signal processing, you might construct a noise model and based on this noise model to detect whether or not a given signal is of pure noise. This type of method often involves hypothesis tests, and test statistics. Based on these things, it rejects or fails to reject a given sample accordingly. This is a quite traditional way to solve your problem.

If you really donot care about details here, you might complete ignore signal and audio. Purely consider what you have are different data streams, and you can use all kind of machine learning methods to differentiate two classes of things, in your case, one is noise and the other is non-noise. If you are going to adopt this approach, python sklearn package will be your good friend with many great tutorials teaching 0-level people to do machine learning.

Finally, let me remind you that one big difference of the later approach from the former one is that you need prepare labels of each signal sample. Otherwise, ML algorithms will have a better chance to differentiate these two classes when you have labels and many samples. Anyhow, both approaches are belonging to the pattern recognition family, and thus they are definitely related to each other. For example, you might view a probabilistic noise model is somewhat a naive bayes classifier.

$\endgroup$
  • $\begingroup$ Was very excited reading about scikit-learn, but its hard for me for now without "near" example. Will give a try to python dejavu. It uses fft to compare audio files. As advised in stackoverflow "the noise files by definition should have a much more even distribution than the normal ones". Suppose it can work. Anyway will learn about ML cause its interesting) $\endgroup$ – cask Oct 2 '14 at 10:31
  • $\begingroup$ Take a look at classification examples, e.g. logistic regression in scikit-learn.org/stable/tutorial/statistical_inference/…. $\endgroup$ – pitfall Feb 3 '15 at 9:28
  • $\begingroup$ All you need to do are : 1) prepare pairwise (X_i, y_i), where X_i is a vector representing your i-th audio signal, and y_i = 1 if this signal is noise, and 0 otherwise; 2) repeat step 1 for all samples you have; 3) say after step 2) you have K samples, you then make a big feature vector XX= [X_1;X_2;...;X_K], where its i-th row is your i-th feature X_i, and also a big label vector Y = [y_1;y_2;...;y_K]; 4) call any sklearn classification function to train a model, say CLF=LogisticRegression.fit( XX, y ); 5) call CLF.predict( X_new ) to predict the class of a new sample, where 1 means noise. $\endgroup$ – pitfall Feb 3 '15 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.