Closed rawatnaresh closed 3 years ago
rnnoise doesn't write WAV files, it just writes raw signed 16-bit PCM data without a header (it also only reads raw PCM data, so it will interpret the WAV header in your input file as audio data). If you want to read the file, you either need to prepend a WAV header to the data, or import it into an audio editor that can handle raw data (most editors can).
Also note that your input file is 44.1 kHz and stereo, but rnnoise only processes 48 kHz mono data. This may be one reason why the generated output doesn't sound very good.
@j-schultz Thank you so much for your quick response. š I tried a couple of ways but I'm still confused. š
Does it have to be a .wav
file to use this module? I'd like to perform noise suppression on raw data. Let's say I'm recording 48kHz mono audio from the microphone and I'm storing all the buffers in a .raw
file.
./rnnoise test.raw out.wav
and I using that raw file as an input to rnnoise
and after the output is generated I'm prepending the WAV headers just like you suggested. I'm able to play the outputted WAV file but I hear nothing(just some random noise)
I cannot just store the recorded file as a WAV
file because, as you mentioned, it'll interpret the WAV headers as data and that can add noise to the output audio.
I'm confused about how I can use this with simple raw data.
As mentioned, the example code takes raw, 16-bit audio (mono, 48000 Hz) and outputs raw audio in the same format. The data you put into the example code shouldn't have WAV headers, and the data that is output will not contain them either, unless you modify it.
@rawatnaresh, I encountered the same issue to get a playable file afterward.
I managed to create a valid .wav file from the raw PCM data generated by this lib using audacity.
File
> Import
> Raw data ...
exiftool noisy.wav
returned:
ExifTool Version Number : 12.26
File Name : noisy.wav
Directory : .
File Size : 294 MiB
File Modification Date/Time : 2021:10:09 11:02:19+02:00
File Access Date/Time : 2021:10:09 11:02:19+02:00
File Inode Change Date/Time : 2021:10:09 11:02:19+02:00
File Permissions : -rw-r--r--
File Type : WAV
File Type Extension : wav
MIME Type : audio/x-wav
Encoding : Microsoft PCM
Num Channels : 2
Sample Rate : 44100
Avg Bytes Per Sec : 176400
Bits Per Sample : 16
Cue Points : (Binary data 28 bytes, use -b option to extract)
Cue Point Label : 1 Tempo: 120.0
Description :
Originator : GarageBand
Originator Reference :
Date/Time Original : 2021:10:09 11:02:17
Time Reference : 1764000
BWF Version : 1
BWF UMID : 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005A001E79
Coding History :
Duration : 0:29:07
I can see it's encoded with 16 bits, uses 2 channels, and has a sample rate of 44 100 Hz
Tada! Your file should be playable and you can export it to another format
Just to simplify things I've pasted everything into a folder
rnnoise
I've copied :
librnnoise.0.dylib
from./libs
rnnoise.h
from./include
rnnoise_demo.c
from./examples
and also addedtest_noise.wav
into the same directorythen I ran
and
but it gave the error
so to fix that
and ran the command again
I can see the new file but it's not playable AudioFiles.zip
am I missing some steps here?
Environments
GCC version
and macOS Catalina 10.15.7