GTCRN Speech Enhancement
repository·main·Indexed 20 days ago
https://github.com/xiaobin-rong/gtcrnAn ultra-lightweight speech enhancement model (48.2K parameters) designed for high-performance speech cleaning with low computational overhead. It supports real-time streaming inference via ONNX Runtime and includes a LADSPA plugin (gtcrn-ladspa-ort) for Linux systems, compatible with PipeWire for system-wide noise suppression.
What's inside GTCRN
- GTCRN (Grouped Temporal Convolutional Recurrent Network) is an ultra-lightweight speech enhancement model designed for minimal computational resource usage. It features approximately 48.2K parameters and 33.0 MMACs per second. It is designed to outperform lightweight models like RNNoise while remaining competitive with much larger baseline models in terms of speech quality metrics (SISNR, PESQ, STOI, etc.).
Streaming Inference with GTCRN
mainGTCRN supports streaming conversion, following a method consistent with the TRT-SE repository. Due to the ultra-low complexity of the GTCRN model, it can be deployed using ONNX and perform inference on the CPU.Use pre-trained GTCRN models
mainPre-trained models for GTCRN are available in the
checkpointsdirectory. These models have been trained on the following datasets:- DNS3
- VCTK-DEMAND
To run inference using these models, use the
infer.pyscript provided in the repository.python infer.pyBuild the GTCRN LADSPA Plugin
mainYou can build the GTCRN LADSPA plugin using three different methods depending on your requirements for portability, size, or development speed:
Minimal Build (Static Link - Docker): Produces the smallest, single-file plugin (~12MB) with no external dependencies. Best for distribution.
- Run
./build-minimal-docker.shto build the minimal runtime (takes 5-20 minutes). - Run
./build.sh minimalto build the plugin.
- Run
Static Build (Download - Bundled): Downloads and bundles the official Microsoft ONNX Runtime. Easier than Docker but results in a larger file (~22MB).
- Run
./build.sh static.
- Run
Dynamic Build (System Lib): Fastest for development, but requires
onnxruntimeto be already installed on your system.- Run
./build.sh dynamic.
- Run
# Minimal Build ./build-minimal-docker.sh ./build.sh minimal # Static Build ./build.sh static # Dynamic Build ./build.sh dynamicPerform streaming inference with GTCRN
mainGTCRN supports streaming inference, which is optimized for real-time applications. Implementation details and demonstrations for streaming can be found in thestreamfolder. On hardware such as a 12th Gen Intel(R) Core(TM) i5-12400 CPU @ 2.50 GHz, the model achieves a real-time factor (RTF) of 0.07.Configure GTCRN as a PipeWire Noise Suppression Filter
mainTo use the GTCRN plugin as a system-wide noise suppression filter in PipeWire, follow these steps:
- Install: Copy the compiled
.sofile to your LADSPA directory (e.g.,/usr/lib/ladspa/libgtcrn_ladspa.so). - Configure: Create a PipeWire filter-chain configuration file at
~/.config/pipewire/filter-chain.conf.d/gtcrn.conf. - Run: Start PipeWire using the configuration file.
Plugin Details for Configuration:
- Plugin Name:
libgtcrn_ladspa - Label:
gtcrn_mono - Controls:
Strength: A value from0.0(Original) to1.0(Fully Processed).Model (0=Light 1=Full): Selects the model complexity (0for Light,1for Full).
context.modules = [ { name = libpipewire-module-filter-chain args = { node.description = "Noise Canceling Microphone (GTCRN)" media.name = "Noise Canceling Microphone (GTCRN)" filter.graph = { nodes = [ { type = ladspa name = "gtcrn" plugin = "libgtcrn_ladspa" label = "gtcrn_mono" control = { # Strength: 0.0 (Original) to 1.0 (Fully Processed) "Strength" = 1.0 "Model (0=Light 1=Full)" = 1 } } ] } audio.channels = 1 capture.props = { node.passive = true } playback.props = { media.class = "Audio/Source" } } } ]- Install: Copy the compiled
Use the GTCRN LADSPA plugin for Linux
mainA LADSPA plugin is available for filtering live audio on Linux systems using
pipewire. This plugin is implemented via ONNX Runtime (packagegtcrn-ladspa-ort).Note: LADSPA support is currently experimental and is maintained by community contributor Bruno Gonçalves.
Select a GTCRN model type
mainThe
gtcrn-ladspa-ortpackage provides two model variants via theModelTypeenum. You can choose between a faster, lighter model or a full-quality model.ModelType::Simple: A lighter, faster model (gtcrn_simple.onnx).ModelType::Full: A full-quality model (gtcrn.onnx).
You can also convert a control value (float) to a
ModelTypeusingModelType::from_control(value), where values $\ge 0.5$ selectFulland values $< 0.5$ selectSimple.use gtcrn_ladspa_ort::{ModelType}; let simple_model = ModelType::Simple; let full_model = ModelType::Full; // Convert from a control value let type_from_val = ModelType::from_control(0.7); assert_eq!(type_from_val, ModelType::Full);Switch model types at runtime
mainYou can switch between
ModelType::SimpleandModelType::Fullon an existingGtcrnModelinstance usingset_model_type. Note that switching models will reload the ONNX session and automatically reset the internal recurrent state to zeros to ensure consistency.let mut model = GtcrnModel::new(ModelType::Simple); // Switch to full quality model // This reloads the session and resets the state model.set_model_type(ModelType::Full);Retrieve the LADSPA plugin descriptor via get_ladspa_descriptor
mainThe function
get_ladspa_descriptoris the primary entry point for LADSPA hosts to discover the plugin's capabilities, ports, and metadata. It must be called withindex == 0to return thePluginDescriptor.Returns:
Option<PluginDescriptor>containing the plugin's unique ID, name, maker, copyright, and port definitions.#[no_mangle] pub extern "C" fn get_ladspa_descriptor(index: u64) -> Option<PluginDescriptor> { // ... }Initialize a GtcrnModel
mainTo use the GTCRN model for inference, instantiate a
GtcrnModel. You can either specify aModelTypeexplicitly or use the default (which isModelType::Simple).use gtcrn_ladspa_ort::{GtcrnModel, ModelType}; // Create a specific model type let mut model = GtcrnModel::new(ModelType::Full); // Or use the default (Simple model) let mut model_default = GtcrnModel::new_default();Initialize the StftProcessor for GTCRN
mainTo perform real-time STFT/iSTFT processing compatible with GTCRN, use
StftProcessor::new. For perfect reconstruction with 50% overlap, you must use annfftof 512 and ahop_sizeof 256. The processor automatically applies asqrt(hann)window to both analysis and synthesis stages to ensure mathematical consistency.use crate::stft::{StftProcessor, NFFT, HOP_SIZE}; // For GTCRN compatibility: let mut processor = StftProcessor::new(NFFT, HOP_SIZE);