Giter Club home page Giter Club logo

wavelet-denoiser's Introduction

TL;DR

python3 src/denoiser-argument.py -i <input file path> -o <output file path>

For an extensive list of what arguments you can pass

python3 src/denoiser-argument.py --help
 usage: denoiser-argument.py [-h] -i INPUT [-a A] [-b B] [-c C] [-d D]
							  [-type {1,2,3}] [-akg AKG] [-ako AKO]
							  [-aks {asc,desc}] [-l L] [-wavelet WAVELET]
							  [-method {wpa,dwt}] [-t TIME] [-v] -o OUTPUT

 optional arguments:
	-h, --help            show this help message and exit
	-i INPUT, --input INPUT
						  the relative or absolute path of the sound file you
						  wish to denoise
	-a A                  denoiser param 'a' (default: 2)
	-b B                  denoiser param 'b' (default: 1)
	-c C                  denoiser param 'c' (default: 1)
	-d D                  denoiser param 'd' (default: 0.1)
	-type {1,2,3}         filter type (default: 1)
	-akg AKG              grad of the Ak filter (default: 4)
	-ako AKO              offset of the Ak filter (default: 2)
	-aks {asc,desc}       the slope of the Ak filter - 'asc' or 'desc' (default:
						  asc)
	-l L                  wavelet packed decomposition levels (default: 8)
	-wavelet WAVELET      the wavelet to be used (default: db8)
	-method {wpa,dwt}     The wavelet transform method - 'wpa' or 'dwt'
						  (default: wpa)
	-t TIME, --time TIME  the period of silence present in the audio file (in
						  seconds) eg: '0-0.5'. If none provided, the noise
						  period will be autoimatically found
	-v, --verbose         verbose (plays the result audio)
	-o OUTPUT, --output OUTPUT
						  The output filename

comment: org-mode in emacs is awesome for writing this kind of documents :)

Docker way

First run docker-compose build, and then

docker-compose run denoiser python3 src/denoiser-argument.py -i test/resources/sp01_airport_sn5_44100.wav -o denoised.wav

You should see something like

trying to open test/resources/sp01_airport_sn5_44100.wav
Number of samples read: 124192
Denoiser options: 
a: 2
b: 1
c: 1
d: 0.1
akGrad: 4
akOffset: 2
filterType: 1
method: wpa
wavelet: db8
Noise profiler finished
0%
1%
...
99%
100%
will write denoised file to denoised.wav
OK

To denoise your own file (let’s say noised.wav)

  • put this file in the root directory
  • run docker-compose run denoiser python3 src/denoiser-argument.py -i noised.wav -o denoised.wav
  • profit :)

If you don’t want to use docker-compose and only docker

  • docker build . -t actondev/denoiser
  • and then
    docker run -v $(pwd):/code actondev/denoiser python3 src/denoiser-argument.py -i test/resources/sp01_airport_sn5_44100.wav -o denoised.wav
        

Wavelet denoiser

This is the product of my thesis for my Electrical & Computer Engineering diploma at Aristotle University of Thessaloniki. Good times (nah not really. i’m lazy, and doing this while having a day-job.. mierda)

Open sourced for 2 reasons

  • other people can use it
  • other people can improve it/comment on how to improve it ..aka tell me how much shitty the code -or the math- is :)

It’s my first attempt to try to do something in the open source world.

echo "Hello open source world"
Hello open source world

Installation

  • sudo apt-get install python3 python3-setuptools python3-pip
  • pip3 install -r requirements.txt

or instad of pip3 you can run python3 -m pip

Windows

with the above, python3 is available with the python command. Change this to python3 like that, by using git bash

python3 vs python fix

If you are on windows, and your executable to run python is.. python (even though it’s version 3) then using git bash:

  • which python

will tell you the path of the executable for the python

  • make sure python -V shows version 3
  • ln -s /path/of/python/from/which/python/command ~/bin
  • edit the environment variables for your current user, and add the C:\users\USERNAME\bin there

For example, I had to run ln -s /c/Python36/python.exe ~/bin/python3.exe

This wall make python3 available in the cmd console of windows as well (useful in case you run the tests from Visual Studio Code in Windows)

A simpler way, to just make the python3 command available in git bash would be to

  • vim ~/.bashrc
alias python3="python"
  • source ~/.bashrc

Usage

Denoiser

run python3 denoiser-argument.py -i <input file path> -o <output file path>. For all the parameters you can pass to the denoiser, run python3 denoiser-argument --help

Denoised file metrics

If you have the clean audio file (that is then noisified)

  • denoise the file
  • calculate the denoiser metric
    =python3 src/metric-cci.py -a “the clean file .wav” -b “the denoised file.wav”=

Available wavelets

[‘bior1.1’, ‘bior1.3’, ‘bior1.5’, ‘bior2.2’, ‘bior2.4’, ‘bior2.6’, ‘bior2.8’, ‘bior3.1’, ‘bior3.3’, ‘bior3.5’, ‘bior3.7’, ‘bior3.9’, ‘bior4.4’, ‘bior5.5’, ‘bior6.8’, ‘cgau1’, ‘cgau2’, ‘cgau3’, ‘cgau4’, ‘cgau5’, ‘cgau6’, ‘cgau7’, ‘cgau8’, ‘cmor’, ‘coif1’, ‘coif2’, ‘coif3’, ‘coif4’, ‘coif5’, ‘coif6’, ‘coif7’, ‘coif8’, ‘coif9’, ‘coif10’, ‘coif11’, ‘coif12’, ‘coif13’, ‘coif14’, ‘coif15’, ‘coif16’, ‘coif17’, ‘db1’, ‘db2’, ‘db3’, ‘db4’, ‘db5’, ‘db6’, ‘db7’, ‘db8’, ‘db9’, ‘db10’, ‘db11’, ‘db12’, ‘db13’, ‘db14’, ‘db15’, ‘db16’, ‘db17’, ‘db18’, ‘db19’, ‘db20’, ‘db21’, ‘db22’, ‘db23’, ‘db24’, ‘db25’, ‘db26’, ‘db27’, ‘db28’, ‘db29’, ‘db30’, ‘db31’, ‘db32’, ‘db33’, ‘db34’, ‘db35’, ‘db36’, ‘db37’, ‘db38’, ‘dmey’, ‘fbsp’, ‘gaus1’, ‘gaus2’, ‘gaus3’, ‘gaus4’, ‘gaus5’, ‘gaus6’, ‘gaus7’, ‘gaus8’, ‘haar’, ‘mexh’, ‘morl’, ‘rbio1.1’, ‘rbio1.3’, ‘rbio1.5’, ‘rbio2.2’, ‘rbio2.4’, ‘rbio2.6’, ‘rbio2.8’, ‘rbio3.1’, ‘rbio3.3’, ‘rbio3.5’, ‘rbio3.7’, ‘rbio3.9’, ‘rbio4.4’, ‘rbio5.5’, ‘rbio6.8’, ‘shan’, ‘sym2’, ‘sym3’, ‘sym4’, ‘sym5’, ‘sym6’, ‘sym7’, ‘sym8’, ‘sym9’, ‘sym10’, ‘sym11’, ‘sym12’, ‘sym13’, ‘sym14’, ‘sym15’, ‘sym16’, ‘sym17’, ‘sym18’, ‘sym19’, ‘sym20’]

..though some give errors. See more here

Running the tests

python3 -m unittest discover -v -s ./test -p '*test*.py'

Continuous Integration

Had the project initially just on gitlab and started using gitlab-ci.. seems quite nice :) It can integrate with public github repos as well. Hooray

Known problems

  • [ ] the denoiser is optimized for input files of 44100 kHz samplerate.

wavelet-denoiser's People

Contributors

actondev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wavelet-denoiser's Issues

cant import pywt WaveletPacket

Hi,
Thanks for sharing your work. I'm trying to use this on an audio pipeline.

Trying to use the denoiser-argument.py script. Have installed all reqs.

when i do something like:
python waveletdenoiser/denoiser-argument.py -i out16km.wav -o outdenoised.wav

i get

AttributeError: module 'pywt' has no attribute 'WaveletPacket'

any suggestions? Does pywt work properly on your system?
perhaps if you have an earlier version than 1.0.6 which is the current one,
this should be put to the requirements.txt

ps. using anaconda distribution of py3.6

Denoising this reverb filter

Hi,

I am a software research trying to denoise the following reverb filter file which was recorded from an MP3 player by playing an impulse wave with a reverb effect.

https://drive.google.com/file/d/1zOX5rUp4C-GO0PpZNcrKJ07a5B_ba5tO/view?usp=sharing

[
제목 없음
myfilter.zip

](url)

I convoluted this filter with my target music file to create a music file that has a reverb effect. However, As you can see from the above filter, this reverb filter has some noise (generated while physically recording the filter by using a cable), which I think is the cause of the faint resulting sound compared to a reverb music directly played by the MP3 player.

So my goal is to denoise the above filter. But I am not sure what will be the best configuration setup for your software to denoise this filter... Which one-line command do you think would do the best job for this? I would really appreciate your help.

Running out of memory

When the audio file is 10 min +, my PC with 8GB of RAM runs out of memory. How can I process the audio using some chunks system, to reduce the memory usage?

maybe use sounddevice.wait() at end of program?

The code currently uses
time.sleep("4")
to delay at the end of the program while audio is played.

You could use:
sounddevice.wait()
to play the file, wait until it is finished, then exit. For short files, this avoids having to
wait extra time after the audio has played.

Very nice program! Thanks!

John P

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.