GithubHelp home page GithubHelp logo

jagger2048 / rnnoise-windows Goto Github PK

View Code? Open in Web Editor NEW
124.0 3.0 43.0 8.07 MB

This is a RNNoise windows demo. It was modified and restructured so that it can be compiled with MSVC, VS2017, VS2019.

C++ 0.05% C 97.49% Python 2.32% CMake 0.12% Shell 0.02%
rnnoise noise-reduction rnnoise-windows msvc

rnnoise-windows's Introduction

rnnoise-windows

This is a RNNoise windows platform demo. It was modified and restructured so that it can be compiled with MSVC, VS2017, VS2019. Apart from this, this project also has the cmake support for other platforms.

What is the changes

Some codes in the files, ./src/celt_lpc.c , ./src/pitch.c , have been modified so that rnnoise can run at the windows platform. These code s had been written in C99 standard and MSVC can not support these language standard completely, e.g. VLA.

Some training python scripts have been changed for fixing the bugs and can easy to use.

Usage:

You can reference the rnnoise_demo() function in the vs project Rnnoise-windows for more details.

  1. Initialize the rnnoise module.

    DenoiseState* pRnnoise = rnnoise_create(NULL);
  2. rnnoise frame process and output

    for (size_t n = 0; n < totalFrameCnt / 480; n++) {
        get_frame_f32(pWavIn, frameIn, 480); // get f32 pcm data
    
        rnnoise_process(pRnnoise, frameOut, frameIn); // rnnoise frame process
    if (isOutput) {
            write_frames_f32(pWavOut, 480, frameOut); // output to wav file
        }
    }
    
3. destroy rnnoise object

```c++
   rnnoise_destroy(pRnnoise);

Performance

Rnnoise has a excellent performance for the steady noise. Meanwhile, it can also work with the music noise situation. It depends on the model you train.

Test 1: speech with pink noise

Test 2: car noise + music + speech

How to train your model

The model locates at the file ./src/rnn_data.c. If you want to use a new model, you can just replace the file with your trained model.

Training steps

You should install below tools before training:

Tensorflow, python, Keras

It is a good choice to use Anaconda to manage your training environment, especially for windows platform.

  1. Install the training environment

    • download and install anaconda from the link.

    • create a virtual training environment

      • open your command line and create python 3.7 virtual environment name tf.

        conda create -n tf python=3.7
        
      • activate the virtual environment

        activate tf // for linux the command is source activate tf 
        
      • install tensorflow in the virtual environment

        conda install tensorflow
        
      • install keras in the virtual environment

        conda install keras
        
      • finally, start training( not yet right now)

        python rnn_train.py ...
        
  2. Prepare the feature set for training

    Generate the feature set to train a new model needs two wav files, one is the clean speech and the other is the noise data.

    • Complier a tool to convert the two file into a feature set

      • For WSL/Linux user:
      cd src
      ./train_complie.sh
      

      It will generate a tool which can help you convert the two file into a feature set. For example

      # ./denoise_training
      	usage: ./denoise_training <speech> <noise> <loop_count> <output feature>
      	
      # ./denoise_training clean_speech.wav noise.wav 50000 feature.dat
      matrix size: 50000 x 87
      

      The file feature.dat contains the feature needed.

      • For windows user, you can use the vs project rnnoise-training to generate a .exe executable program and run as above mention. The default .exe file located at rnnoise-windows\x64\Debug\ directory.
    • Convert the feature into h5 format

      First copy the file generated last step into the my-training directory. Then run a python script convert the feature into h5 format. Open your command line reference as below commands.

      # cd training
      # mv ../src/feature.dat .
      # python bin2hdf5.py --bin_file feature.dat --matrix_shape 50000x87
      

      These commands will generate a .h5 file for the next step.

  3. Training

    python rnn_train.py xxx.h5
    
  4. Capture the new model

    # python dump_rnn.py
    

Finally, copy the file rnn_data.c into src directory and recompile the project . Then run and check the result of new model. Have fun.

PS:

The training script has a function called "resume from break point". While the rnn_train.py script is running, it will generate and scan a middle weight mid_weights.hdf5. If exits this file at the same directory when the scripts is started at the first time, it will continue the training process follow the last epoch. The script midWeight2Final.py will help you convert the midweight to the final weight which can be dumped to a new model.

Update log

Version log
1.2.1 fix cmake support for Linux/wsl platform; fix output stream missing bug in denoise.c when training
1.2 update training steps and merge the code from official branch, cmake support fails at this version
1.1 remove some extra files and test for vs2019
1.0 add cmake support and test for vs2017

Reference:

rnnoise-windows's People

Contributors

avenema avatar jagger2048 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rnnoise-windows's Issues

Please add the license

The original project has BSD-3-Clause license, but this repo doesn't mention any license.
If it is not open source, please clearly state it.

Thanks in advance.

How to denoise 16K wav file

I try to use 16K wav file as program input, then transcoded to 16k output, tut the noise reduction effect is poor

denoise_training use error(when trying to generate a feature.dat)

When I use src/complie.sh to constract a denoise_training tool.

I found that when I run the following in linux:

./denoise_training TRAIN_DR1_MRDD0_SI1680.WAV n95.wav 10000 feature.dat
There is an error:
image
but when I follow the instruction and run this:
./denoise_training TRAIN_DR1_MRDD0_SI1680.WAV n95.wav 10000
The date all directly outputs on the terminal like that
image

Using a resampler for 16KHz

Hello @jagger2048, thanks for your Windows adaption, I have successfully trained my own model and it is working really well with your adaption using 48KHz.

Now I need to add RNNoise to the Mozilla's DeepSpeech feeding pipeline, first I'm experimenting with your adaption and https://github.com/cpuimage/resampler to up-sample/down-sample. It is working but it generates a weird sound like static:
cleanspeech.zip

The code that I'm using with the resampler mentioned above :

https://gist.github.com/carlfm01/c8f49562b97a66fea1a72d23d1259b7d

Any idea of what's wrong?

Thanks.

dll-version

Hello,

I`m using the original rnnoise at a probject that runs on Linux- and WIndows-machines. So I would like zo build rnnoise for windows as a dll that has the exact same entrypoints as the original version... to be able to use the dotnet part unchanged on Linux and Windows.

Sadly, my c++-skills aren´t the best... can anyone help me?

Thanks alot.

Carl

rnn train always stop

clean audio is silent audio, noise audio is pink noise audio, 175MB/48000hz/1channel/S16le

while exec python rnn_train.py feature.h5, it always stop here
image

Question difference between this and original

I have built an executable using the original RNNoise code on Windows, but when executing it, it didn't work (I only obtain a noisy output). Your code on the other hand works. What are the changes that you made to the original code to make it Windows compatible? Was the problem in the src or the example code?

How to train this with larger dataset (More than just a pair of noise data and clean speech)

Hello,
I believe that this is a fairly simple question but since I'm very new to ML in general, it still baffles me. I just followed the training instruction and has successfully trained my model on one pair of data (a clean speech.wav and a noise.wav) now I want to ask how can you repeat this process for larger dataset, I'm currently having a set of data with 300 files for these 2 categories and I don't think repeating this process 300 times is the way I should go.

Thanks.

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.