### Install nnnoiseless as C library Source: https://github.com/jneem/nnnoiseless/blob/main/README.md Install nnnoiseless as a C-compatible library using cargo-c. This involves creating a staging directory and copying files to the system root. ```sh cargo install cargo-c $ mkdir staging-nnnoiseless $ cargo cinstall --destdir staging-nnnoiseless $ sudo cp -a staging-nnnoiseless/* / ``` -------------------------------- ### Install nnnoiseless CLI Source: https://github.com/jneem/nnnoiseless/blob/main/README.md Install the nnnoiseless command-line tool using cargo. Ensure Rust is installed first. ```bash cargo install nnnoiseless ``` -------------------------------- ### Build C Library with cargo-c Source: https://context7.com/jneem/nnnoiseless/llms.txt Installs cargo-c and builds the nnnoiseless C library, including header and library files. These are then copied to system directories for use by C/C++ applications. ```bash # Install cargo-c and build the C library cargo install cargo-c mkdir staging-nnnoiseless cargo cinstall --destdir staging-nnnoiseless sudo cp -a staging-nnnoiseless/* / # Compile C program gcc -o denoise main.c -lnnnoiseless ``` -------------------------------- ### nnnoiseless CLI Help Source: https://github.com/jneem/nnnoiseless/blob/main/README.md View advanced usage options for the nnnoiseless command-line tool by running the --help command. ```bash nnnoiseless --help ``` -------------------------------- ### Run nnnoiseless CLI Source: https://github.com/jneem/nnnoiseless/blob/main/README.md Use the nnnoiseless command-line tool to process WAV or RAW PCM files. Specify input and output file paths. ```bash nnnoiseless input.wav output.wav ``` -------------------------------- ### Prepare Speech and Noise Samples Source: https://context7.com/jneem/nnnoiseless/llms.txt Convert audio files to 48kHz mono WAV format using ffmpeg. This is a prerequisite for generating training features. ```bash ffmpeg -i speech_sample.mp3 -f s16le -ac 1 -ar 48000 speech.wav ``` ```bash ffmpeg -i noise_sample.mp3 -f s16le -ac 1 -ar 48000 noise.wav ``` -------------------------------- ### Load Custom nnnoiseless Model Source: https://github.com/jneem/nnnoiseless/blob/main/README.md Use a custom neural network model with the nnnoiseless binary by specifying the --model option with the path to the model weights file. ```bash nnnoiseless --model=weights.rnn input.wav output.wav ``` -------------------------------- ### Training Custom Models Source: https://context7.com/jneem/nnnoiseless/llms.txt Utilizes built-in training utilities to train custom neural network weights for specialized noise environments. This command initiates the training process. ```bash # Training command placeholder - actual command depends on specific training setup # Example: cargo run --release --features=cli -- train --config training.toml ``` -------------------------------- ### Command Line Tool Source: https://context7.com/jneem/nnnoiseless/llms.txt The nnnoiseless command-line tool processes WAV or raw PCM files. It automatically detects WAV files by extension and handles sample rate conversion. ```APIDOC ## Command Line Tool ### Description The nnnoiseless command-line tool processes WAV or raw PCM files. It automatically detects WAV files by extension and handles sample rate conversion. ### Usage ```bash # Install the command-line tool cargo install nnnoiseless # Basic usage - denoise a WAV file nnoiseless input.wav output.wav # Process with a custom model nnoiseless --model=custom_weights.rnn input.wav output.wav # Process raw PCM with custom sample rate and channels nnoiseless --sample-rate=44100 --channels=2 input.raw output.raw # Force WAV output format nnoiseless input.raw --wav-out output.wav # View all options nnoiseless --help ``` ``` -------------------------------- ### nnnoiseless CLI with Custom Model Source: https://context7.com/jneem/nnnoiseless/llms.txt Processes an input file using a specified custom model file. Ensure the model file path is correct. ```bash nnnoiseless --model=custom_weights.rnn input.wav output.wav ``` -------------------------------- ### Convert Audio Files with ffmpeg Source: https://github.com/jneem/nnnoiseless/blob/main/train/README.md Use ffmpeg to convert audio files to 16-bit, little-endian, 48kHz, 1-channel WAV format, which is required for training. ```bash ffmpeg -i $file -f s16le -ac 1 -ar 48000 output.wav ``` -------------------------------- ### Run nnnoiseless with Trained Model Source: https://github.com/jneem/nnnoiseless/blob/main/train/README.md Use the trained model weights (`weights.rnn`) with the `nnnoiseless` binary to perform noise reduction on input audio. Specify the model file, input file, and output file. ```bash cargo run --release -- --model weights.rnn ``` -------------------------------- ### nnnoiseless CLI for Raw PCM Source: https://context7.com/jneem/nnnoiseless/llms.txt Processes raw PCM audio data, allowing specification of sample rate and number of channels. Output is saved to a raw file. ```bash nnnoiseless --sample-rate=44100 --channels=2 input.raw output.raw ``` -------------------------------- ### Create DenoiseState with Built-in Model Source: https://context7.com/jneem/nnnoiseless/llms.txt Initializes a new denoising state using the default neural network model. The `DenoiseState` struct manages audio processing buffers. Input audio should be in the i16 range. ```rust use nnnoiseless::DenoiseState; // Create a new denoising state let mut denoise = DenoiseState::new(); // One second of noisy audio at 48kHz sample rate // Note: Input values should be in i16 range (-32768 to 32767), not normalized float (-1.0 to 1.0) let noisy_audio: Vec = (0..48_000) .map(|x| { let signal = (x as f32 * 440.0 * 2.0 * std::f32::consts::PI / 48_000.0).sin() * 16000.0; let noise = (x as f32 * 0.1).sin() * 1000.0; // Simulated noise signal + noise }) .collect(); let mut output = Vec::new(); let mut out_buf = [0.0; DenoiseState::FRAME_SIZE]; // 480 samples per frame let mut first = true; for chunk in noisy_audio.chunks_exact(DenoiseState::FRAME_SIZE) { denoise.process_frame(&mut out_buf[..], chunk); // Discard first frame due to fade-in artifacts if !first { output.extend_from_slice(&out_buf[..]); } first = false; } // output now contains denoised audio ``` -------------------------------- ### Use Converted RNNoise Model with nnnoiseless Source: https://context7.com/jneem/nnnoiseless/llms.txt Utilize a converted RNNoise model with the nnnoiseless command-line tool for real-time noise reduction. Specify the model file and input/output audio files. ```bash nnnoiseless --model=nnnoiseless_weights.rnn input.wav output.wav ``` -------------------------------- ### Generate Training Data with nnnoiseless Source: https://github.com/jneem/nnnoiseless/blob/main/train/README.md Generate training features from speech and noise WAV files using the `nnnoiseless` training binary. Specify the number of frames and glob patterns for signal and noise files. The output must be named `training.h5`. ```bash cargo run --features=train --bin=train --release -- --count= --signal-glob= --noise-glob= -o training.h5 ``` -------------------------------- ### C API: Basic Denoising Source: https://context7.com/jneem/nnnoiseless/llms.txt Initializes and uses the RNNoise-compatible C API for denoising. Creates a denoiser with a built-in model and processes audio frames. The frame size is fixed at 480 samples. ```c // rnnoise.h is automatically generated by cargo-c #include #include int main() { // Get frame size (480 samples) int frame_size = rnnoise_get_frame_size(); // Create denoiser with built-in model DenoiseState *st = rnnoise_create(NULL); float input[480]; float output[480]; // Fill input with audio samples (values in i16 range) // ... read audio data ... // Process frame, returns VAD probability float vad = rnnoise_process_frame(st, output, input); printf("VAD: %f\n", vad); // Clean up rnnoise_destroy(st); return 0; } ``` -------------------------------- ### C API: Custom Model Loading Source: https://context7.com/jneem/nnnoiseless/llms.txt Loads and uses a custom model from a file within a C application. The model is loaded from a file pointer and then used to create a denoiser instance. ```c #include #include int main() { // Load custom model from file FILE *model_file = fopen("custom_weights.rnn", "rb"); RNNModel *model = rnnoise_model_from_file(model_file); // Note: model_file is closed by rnnoise_model_from_file if (model == NULL) { fprintf(stderr, "Failed to load model\n"); return 1; } // Create denoiser with custom model DenoiseState *st = rnnoise_create(model); float input[480]; float output[480]; // Process audio frames rnnoise_process_frame(st, output, input); // Clean up rnnoise_destroy(st); rnnoise_model_free(model); return 0; } ``` -------------------------------- ### DenoiseSignal with Custom Model Source: https://context7.com/jneem/nnnoiseless/llms.txt Creates a `DenoiseSignal` with a custom model that is borrowed and shared across channels. Ensure the model file is valid and loaded correctly. ```rust use nnnoiseless::dasp::signal::{self, Signal}; use nnnoiseless::{DenoiseSignal, RnnModel}; // Load custom model let model_data = std::fs::read("voice_model.rnn").expect("Failed to read model"); let model = RnnModel::from_bytes(&model_data).expect("Invalid model"); // Create signal source (could be from file, microphone, etc.) let audio_source = signal::rate(48_000.0).const_hz(440.0).sine(); // Apply denoising with custom model let denoised = DenoiseSignal::with_model(audio_source, &model); for sample in denoised.take(1000) { // Process denoised samples } ``` -------------------------------- ### Create DenoiseState with Custom Model Source: https://context7.com/jneem/nnnoiseless/llms.txt Initializes a denoising state using a custom neural network model loaded from bytes. This is useful for specialized noise filtering. Ensure the model data is correctly formatted. ```rust use nnnoiseless::{DenoiseState, RnnModel}; // Load custom model from bytes (e.g., embedded at compile time) let model_data: &[u8] = include_bytes!("path/to/custom_weights.rnn"); let model = RnnModel::from_bytes(model_data).expect("Failed to load model"); // Create denoiser with custom model let mut denoise = DenoiseState::from_model(model); let input: [f32; 480] = [0.0; 480]; let mut output = [0.0f32; 480]; denoise.process_frame(&mut output, &input); ``` -------------------------------- ### Create DenoiseState Borrowing a Custom Model Source: https://context7.com/jneem/nnnoiseless/llms.txt Creates a denoising state that borrows a shared custom model. This allows multiple `DenoiseState` instances to use the same model, which is efficient for multi-channel processing. The model is loaded once from a file. ```rust use nnnoiseless::{DenoiseState, RnnModel}; // Load model once let model_data = std::fs::read("weights.rnn").expect("Failed to read model file"); let model = RnnModel::from_bytes(&model_data).expect("Failed to parse model"); // Create multiple denoisers sharing the same model (for stereo audio) let mut left_channel = DenoiseState::with_model(&model); let mut right_channel = DenoiseState::with_model(&model); let left_input: [f32; 480] = [0.0; 480]; let right_input: [f32; 480] = [0.0; 480]; let mut left_output = [0.0f32; 480]; let mut right_output = [0.0f32; 480]; left_channel.process_frame(&mut left_output, &left_input); right_channel.process_frame(&mut right_output, &right_input); ``` -------------------------------- ### C API Source: https://context7.com/jneem/nnnoiseless/llms.txt nnnoiseless provides an RNNoise-compatible C API for integration with C/C++ applications. ```APIDOC ## C API ### Description nnoiseless provides an RNNoise-compatible C API for integration with C/C++ applications. Install with cargo-c for header and library generation. ### Functions - **rnnoise_get_frame_size()**: Returns the frame size (480 samples). - **rnnoise_create(model)**: Creates a denoiser. Pass `NULL` for the built-in model or a `RNNModel` pointer for a custom model. - **rnnoise_process_frame(state, output, input)**: Processes an audio frame. Returns VAD probability. - **rnnoise_destroy(state)**: Cleans up the denoiser state. ### Example Usage ```c // rnnoise.h is automatically generated by cargo-c #include #include int main() { // Get frame size (480 samples) int frame_size = rnnoise_get_frame_size(); // Create denoiser with built-in model DenoiseState *st = rnnoise_create(NULL); float input[480]; float output[480]; // Fill input with audio samples (values in i16 range) // ... read audio data ... // Process frame, returns VAD probability float vad = rnnoise_process_frame(st, output, input); printf("VAD: %f\n", vad); // Clean up rnnoise_destroy(st); return 0; } ``` ### Build Instructions ```bash # Install cargo-c and build the C library cargo install cargo-c mkdir staging-nnnoiseless cargo cinstall --destdir staging-nnnoiseless sudo cp -a staging-nnnoiseless/* / # Compile C program gcc -o denoise main.c -lnnnoiseless ``` ``` -------------------------------- ### Custom Model with C API Source: https://context7.com/jneem/nnnoiseless/llms.txt Load and use custom models from C applications. ```APIDOC ## Custom Model with C API ### Description Load and use custom models from C applications. ### Functions - **rnnoise_model_from_file(file_pointer)**: Loads a model from a file pointer. The file is closed by this function. - **rnnoise_create(model)**: Creates a denoiser using the provided custom model. - **rnnoise_destroy(state)**: Cleans up the denoiser state. - **rnnoise_model_free(model)**: Frees the memory associated with the custom model. ### Example Usage ```c #include #include int main() { // Load custom model from file FILE *model_file = fopen("custom_weights.rnn", "rb"); RNNModel *model = rnnoise_model_from_file(model_file); // Note: model_file is closed by rnnoise_model_from_file if (model == NULL) { fprintf(stderr, "Failed to load model\n"); return 1; } // Create denoiser with custom model DenoiseState *st = rnnoise_create(model); float input[480]; float output[480]; // Process audio frames rnnoise_process_frame(st, output, input); // Clean up rnnoise_destroy(st); rnnoise_model_free(model); return 0; } ``` ``` -------------------------------- ### Training Custom Models Source: https://context7.com/jneem/nnnoiseless/llms.txt Train custom neural network weights for specialized noise environments using the built-in training utilities. ```APIDOC ## Training Custom Models ### Description Train custom neural network weights for specialized noise environments using the built-in training utilities. ### Usage (Specific command-line arguments and options for training are not detailed in the provided text. Please refer to the nnnoiseless documentation or source code for detailed training instructions.) ``` -------------------------------- ### Train the RNN Model with Python Script Source: https://github.com/jneem/nnnoiseless/blob/main/train/README.md Execute the `rnn_train.py` script to train the noise reduction model using the generated `training.h5` file. This process can be time-consuming. ```python python train/rnn_train.py ``` -------------------------------- ### DenoiseSignal::with_model Source: https://context7.com/jneem/nnnoiseless/llms.txt Creates a `DenoiseSignal` with a custom model that is borrowed and shared across channels. ```APIDOC ## DenoiseSignal::with_model ### Description Creates a `DenoiseSignal` with a custom model that is borrowed and shared across channels. ### Method `with_model` ### Parameters #### Request Body - **audio_source** (dasp::signal::Signal) - Required - The input audio signal source. - **model** (*RnnModel) - Required - A reference to the `RnnModel` to use for denoising. ### Response #### Success Response (DenoiseSignal) - **DenoiseSignal** - A denoising signal processor configured with the custom model. ### Request Example ```rust use nnnoiseless::dasp::signal::{self, Signal}; use nnnoiseless::{DenoiseSignal, RnnModel}; // Load custom model let model_data = std::fs::read("voice_model.rnn").expect("Failed to read model"); let model = RnnModel::from_bytes(&model_data).expect("Invalid model"); // Create signal source (could be from file, microphone, etc.) let audio_source = signal::rate(48_000.0).const_hz(440.0).sine(); // Apply denoising with custom model let denoised = DenoiseSignal::with_model(audio_source, &model); for sample in denoised.take(1000) { // Process denoised samples } ``` ``` -------------------------------- ### nnnoiseless CLI Force WAV Output Source: https://context7.com/jneem/nnnoiseless/llms.txt Forces the output to be in WAV format, even when processing raw PCM input. The output file will be saved as a WAV file. ```bash nnnoiseless input.raw --wav-out output.wav ``` -------------------------------- ### DenoiseState::with_model Source: https://context7.com/jneem/nnnoiseless/llms.txt Creates a denoising state that borrows a custom model. Use this when you want to share a single model between multiple `DenoiseState` instances (e.g., for multi-channel audio processing). ```APIDOC ## DenoiseState::with_model ### Description Creates a denoising state that borrows a custom neural network model, allowing for model sharing. ### Method Associated function (constructor) ### Endpoint N/A (Rust function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **model** (`&RnnModel`) - Required - A reference to the custom neural network model to be shared. ### Request Example ```rust use nnnoiseless::{DenoiseState, RnnModel}; // Load model once let model_data = std::fs::read("weights.rnn").expect("Failed to read model file"); let model = RnnModel::from_bytes(&model_data).expect("Failed to parse model"); // Create multiple denoisers sharing the same model (for stereo audio) let mut left_channel = DenoiseState::with_model(&model); let mut right_channel = DenoiseState::with_model(&model); let left_input: [f32; 480] = [0.0; 480]; let right_input: [f32; 480] = [0.0; 480]; let mut left_output = [0.0f32; 480]; let mut right_output = [0.0f32; 480]; left_channel.process_frame(&mut left_output, &left_input); right_channel.process_frame(&mut right_output, &right_input); ``` ### Response N/A (Rust struct instance) ### Response Example N/A ``` -------------------------------- ### DenoiseState::from_model Source: https://context7.com/jneem/nnnoiseless/llms.txt Creates a denoising state with a custom neural network model. Use this when you have trained a specialized model for your particular noise environment or audio type. ```APIDOC ## DenoiseState::from_model ### Description Creates a denoising state initialized with a custom neural network model. ### Method Associated function (constructor) ### Endpoint N/A (Rust function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **model** (`RnnModel`) - Required - The custom neural network model to use for denoising. ### Request Example ```rust use nnnoiseless::{DenoiseState, RnnModel}; // Load custom model from bytes (e.g., embedded at compile time) let model_data: &[u8] = include_bytes!("path/to/custom_weights.rnn"); let model = RnnModel::from_bytes(model_data).expect("Failed to load model"); // Create denoiser with custom model let mut denoise = DenoiseState::from_model(model); let input: [f32; 480] = [0.0; 480]; let mut output = [0.0f32; 480]; denoise.process_frame(&mut output, &input); ``` ### Response N/A (Rust struct instance) ### Response Example N/A ``` -------------------------------- ### Convert RNNoise Model to nnnoiseless Format Source: https://github.com/jneem/nnnoiseless/blob/main/README.md Convert RNNoise model weights from text format to nnnoiseless binary format using the provided Python script. Specify input text file and output binary file. ```python python train/convert_rnnoise.py input_file.txt output_file.rnn ``` -------------------------------- ### Convert RNNoise Model to nnnoiseless Format Source: https://context7.com/jneem/nnnoiseless/llms.txt Convert existing RNNoise models from text format to the nnnoiseless binary format using the provided Python script. This is useful for migrating models. ```bash python train/convert_rnnoise.py rnnoise_weights.txt nnnoiseless_weights.rnn ``` -------------------------------- ### Generate Training Features Source: https://context7.com/jneem/nnnoiseless/llms.txt Generate training features for the noise reduction model using the nnnoiseless training utility. Specify the count of training samples and glob patterns for speech and noise audio files. The output is saved to a specified HDF5 file. ```bash cargo run --features=train --bin=train --release -- \ --count=5000000 \ --signal-glob="/path/to/speech/*.wav" \ --noise-glob="/path/to/noise/*.wav" \ -o training.h5 ``` -------------------------------- ### DenoiseState::process_frame Source: https://context7.com/jneem/nnnoiseless/llms.txt Processes a single frame of audio samples, applying noise reduction. Takes 480 samples of input and produces 480 samples of output. The input and output are `f32` arrays but should contain values in the i16 range (-32768 to 32767). Returns the voice activity detection (VAD) probability. ```APIDOC ## DenoiseState::process_frame ### Description Processes a single frame of audio samples, applying noise reduction. Returns the voice activity detection (VAD) probability. ### Method Instance method ### Endpoint N/A (Rust method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (operates on provided buffers) ### Parameters - **out_buf** (mut `&mut [f32]`) - Required - A mutable slice to store the processed audio frame (480 samples). - **input_frame** (`&[f32]`) - Required - A slice containing the input audio frame (480 samples). Values should be in the i16 range. ### Request Example ```rust use nnnoiseless::DenoiseState; let mut denoise = DenoiseState::new(); let mut out_buf = [0.0f32; DenoiseState::FRAME_SIZE]; // Input frame with values in i16 range let input_frame: [f32; 480] = [0.0; 480]; // Your audio samples here // Process frame and get VAD probability let vad_probability = denoise.process_frame(&mut out_buf[..], &input_frame); println!("Voice activity probability: {}", vad_probability); // vad_probability ranges from 0.0 (no speech) to 1.0 (speech detected) ``` ### Response #### Success Response (200) - **vad_probability** (f32) - The probability of voice activity detected in the frame, ranging from 0.0 to 1.0. ### Response Example ```json { "vad_probability": 0.95 } ``` ``` -------------------------------- ### DenoiseSignal (dasp integration) Source: https://context7.com/jneem/nnnoiseless/llms.txt A high-level wrapper that applies denoising to any dasp `Signal`. Automatically handles frame buffering and conversion. ```APIDOC ## DenoiseSignal (dasp integration) ### Description A high-level wrapper that applies denoising to any dasp `Signal`. Automatically handles frame buffering and conversion, making it easy to integrate with the dasp audio processing ecosystem. ### Method `DenoiseSignal::new` ### Parameters #### Request Body - **signal_source** (dasp::signal::Signal) - Required - The input audio signal source. ### Response #### Success Response (DenoiseSignal) - **DenoiseSignal** - A denoising signal processor. ### Request Example ```rust use nnnoiseless::dasp::signal::{self, Signal}; use nnnoiseless::DenoiseSignal; // Create a noise signal source let noise_source = signal::noise(0); // Wrap it in a denoising signal processor let mut denoised = DenoiseSignal::new(noise_source); // Process samples - output is in normalized float range (-1.0 to 1.0) let samples: Vec = denoised.take(48_000).collect(); println!("Processed {} samples", samples.len()); ``` ``` -------------------------------- ### Load RnnModel from Bytes Source: https://context7.com/jneem/nnnoiseless/llms.txt Loads a neural network model from a byte array. Returns `None` if the model data is invalid or corrupted. Ensure the model file is correctly read into a byte vector. ```rust use nnnoiseless::RnnModel; // Load model from file let model_data = std::fs::read("custom_model.rnn") .expect("Failed to read model file"); let model = RnnModel::from_bytes(&model_data) .expect("Failed to parse model - file may be corrupted"); println!("Model loaded successfully"); ``` -------------------------------- ### DenoiseState::new Source: https://context7.com/jneem/nnnoiseless/llms.txt Creates a new denoising state with the built-in neural network model. The `DenoiseState` is the core struct for noise suppression, containing all necessary buffers for processing audio frames. Since it's a large struct, it returns a boxed instance. ```APIDOC ## DenoiseState::new ### Description Creates a new denoising state with the built-in neural network model. ### Method Associated function (constructor) ### Endpoint N/A (Rust function) ### Parameters None ### Request Example ```rust use nnnoiseless::DenoiseState; // Create a new denoising state let mut denoise = DenoiseState::new(); // One second of noisy audio at 48kHz sample rate // Note: Input values should be in i16 range (-32768 to 32767), not normalized float (-1.0 to 1.0) let noisy_audio: Vec = (0..48_000) .map(|x| { let signal = (x as f32 * 440.0 * 2.0 * std::f32::consts::PI / 48_000.0).sin() * 16000.0; let noise = (x as f32 * 0.1).sin() * 1000.0; // Simulated noise signal + noise }) .collect(); let mut output = Vec::new(); let mut out_buf = [0.0; DenoiseState::FRAME_SIZE]; // 480 samples per frame let mut first = true; for chunk in noisy_audio.chunks_exact(DenoiseState::FRAME_SIZE) { denoise.process_frame(&mut out_buf[..], chunk); // Discard first frame due to fade-in artifacts if !first { output.extend_from_slice(&out_buf[..]); } first = false; } // output now contains denoised audio ``` ### Response N/A (Rust struct instance) ### Response Example N/A ``` -------------------------------- ### Load RnnModel from Static Bytes Source: https://context7.com/jneem/nnnoiseless/llms.txt Loads a model from a static byte array without runtime allocation. Ideal for embedding models at compile time. The model stores references to the provided bytes. ```rust use nnnoiseless::{DenoiseState, RnnModel}; // Embed model at compile time - no runtime allocation static MODEL_WEIGHTS: &[u8] = include_bytes!("../weights.rnn"); let model = RnnModel::from_static_bytes(MODEL_WEIGHTS) .expect("Invalid embedded model"); let denoise = DenoiseState::from_model(model); ``` -------------------------------- ### DenoiseSignal with Dasp Integration Source: https://context7.com/jneem/nnnoiseless/llms.txt A high-level wrapper that applies denoising to any dasp `Signal`. Automatically handles frame buffering and conversion. Output is in the normalized float range (-1.0 to 1.0). ```rust use nnnoiseless::dasp::signal::{self, Signal}; use nnnoiseless::DenoiseSignal; // Create a noise signal source let noise_source = signal::noise(0); // Wrap it in a denoising signal processor let mut denoised = DenoiseSignal::new(noise_source); // Process samples - output is in normalized float range (-1.0 to 1.0) let samples: Vec = denoised.take(48_000).collect(); println!("Processed {} samples", samples.len()); ``` -------------------------------- ### RnnModel::from_static_bytes Source: https://context7.com/jneem/nnnoiseless/llms.txt Loads a model from a static byte array without allocation. Ideal for embedding models at compile time. ```APIDOC ## RnnModel::from_static_bytes ### Description Loads a model from a static byte array without allocation. Ideal for embedding models at compile time, as the model stores references to the provided bytes rather than copying them. ### Method `from_static_bytes` ### Parameters #### Request Body - **static_model_data** (bytes) - Required - The static byte array containing the model data. ### Response #### Success Response (Model) - **RnnModel** - The loaded neural network model. ### Request Example ```rust use nnnoiseless::{ DenoiseState, RnnModel }; // Embed model at compile time - no runtime allocation static MODEL_WEIGHTS: &[u8] = include_bytes!("../weights.rnn"); let model = RnnModel::from_static_bytes(MODEL_WEIGHTS) .expect("Invalid embedded model"); let denoise = DenoiseState::from_model(model); ``` ``` -------------------------------- ### Process Audio Frame with DenoiseState Source: https://context7.com/jneem/nnnoiseless/llms.txt Applies noise reduction to a single 480-sample audio frame. Input and output values should be within the i16 range. Returns the voice activity detection (VAD) probability. ```rust use nnnoiseless::DenoiseState; let mut denoise = DenoiseState::new(); let mut out_buf = [0.0f32; DenoiseState::FRAME_SIZE]; // Input frame with values in i16 range let input_frame: [f32; 480] = [0.0; 480]; // Your audio samples here // Process frame and get VAD probability let vad_probability = denoise.process_frame(&mut out_buf[..], &input_frame); println!("Voice activity probability: {}", vad_probability); // vad_probability ranges from 0.0 (no speech) to 1.0 (speech detected) ``` -------------------------------- ### RnnModel::from_bytes Source: https://context7.com/jneem/nnnoiseless/llms.txt Loads a neural network model from a byte array. Returns None if the model data is invalid or corrupted. ```APIDOC ## RnnModel::from_bytes ### Description Loads a neural network model from a byte array. The model format is the binary format produced by nnnoiseless training scripts. Returns `None` if the model data is invalid or corrupted. ### Method `from_bytes` ### Parameters #### Request Body - **model_data** (bytes) - Required - The byte array containing the model data. ### Response #### Success Response (Model) - **RnnModel** - The loaded neural network model. #### Response Example ```rust use nnnoiseless::RnnModel; // Load model from file let model_data = std::fs::read("custom_model.rnn") .expect("Failed to read model file"); let model = RnnModel::from_bytes(&model_data) .expect("Failed to parse model - file may be corrupted"); println!("Model loaded successfully"); ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.