Python
Python bindings for the Rapidly Audio Engine, designed for ML pipelines and rapid prototyping.
The Rapidly Audio Engine is a model inference library built for audio. A library of pre-trained models covers speech noise suppression and de-reverberation.
Models are trained for real-time use, with latencies down to 11 ms in speech enhancement applications. They are small and resource-efficient, with file sizes down to ~241 KB for the most compact noise-suppression model.
The engine is built in C++ and is compatible across architectures. The Python wrapper makes it easy to integrate Rapidly into Python projects and to process files or benchmark models from a script or notebook.
Getting Started
Installation
Install the Python wrapper with pip:
python -m pip install rapidlyRapidly is compatible with Python 3 and later.
How to Use
The Rapidly Python API wraps the C++ library.
The examples.py script in the Rapidly SDK on GitHub is the fastest starting point. It provides a command-line interface for trying models on audio files without writing code.
- Clone or download
examples.pyfrom the Rapidly SDK repository. - Open a terminal and
cdto the directory. - Run
python examples.pyand follow the on-screen prompts to pick a model and process a file.
Using the API
Import the module and list the available models:
import rapidly
models = rapidly.list_models()
print(models)Download and update to the latest models:
rapidly.update_models()Licensing
A Rapidly license removes audio watermarking and unlocks the model entitlements granted by the key. Without a license, the engine runs in a watermarked demo mode that audibly degrades the output.
License keys have the format lk_<base64url-payload>.<base64url-signature> and are verified offline against an embedded Ed25519 public key. No network access is required.
To obtain a license, contact us.
import rapidly
engine = rapidly.RapidlyEngine()
if not engine.add_license("lk_..."):
raise RuntimeError("Rapidly license could not be verified.")Using the SDK
Process a File
Use process_file for one-shot file conversions:
import rapidly
# Initialize the engine
engine = rapidly.RapidlyEngine()
# List the available models in the models folder
models = rapidly.list_models()
# Create a processor to inspect the available output busses for the chosen model
processor = engine.create_processor(models[0], 2, 44100)
# Read the available output bus names
num_buses = processor.get_number_of_output_buses()
bus_names = [processor.get_output_bus_name(i) for i in range(num_buses)]Then run the file through the model:
rapidly.process_file(
model_file_path=models[0],
input_file_path=input_file_path,
output_file_path=output_file_path,
selected_output_bus=0, # The processed result is on bus 0 in most models
)This applies models[0] to input_file_path and writes the result to output_file_path.
rapidly.process_file uses PySoundFile to read and write audio files. PySoundFile is not required to use Rapidly, but it is a convenient library for handling audio files in Python.
Stream Processing
For real-time or streaming workloads, drive a Processor directly with process():
import numpy as np
import rapidly
engine = rapidly.RapidlyEngine()
processor = engine.create_processor(
"models/speech-denoise-32ms.v1.0.rapidly", 2, 44100
)
# audio_block: np.ndarray of shape (num_samples, num_channels), dtype=float32
processed = processor.process(audio_block)
# Reset between unrelated streams to clear internal delay lines
processor.reset()
# Inspect the model configuration (sample rate, latency, block size, ...)
info = processor.get_info()Parameters
Processor exposes typed getters and setters for the most common controls, plus generic per-bus controls.
| Method | Description |
|---|---|
get_max_attenuation() / set_max_attenuation(value) | Maximum attenuation in dB. Range: (-∞, 0]. |
get_sensitivity() / set_sensitivity(value) | Processing sensitivity. Range: -100% to 100%. 0% is neutral. |
get_output_bus_volume(bus) / set_output_bus_volume(bus, value) | Linear gain for an output bus. Range: 0 and up. |
set_output_bus_sensitivity(bus, value) | Per-bus sensitivity. Range: -100% to 100%. |
get_number_of_output_buses() | Number of output busses available. |
get_output_bus_name(index, max_length=256) | Name of the output bus at index. |
get_parameter_range(parameter_index) | Minimum and maximum values for a parameter ID. |
Models
Models in the models folder use clear, descriptive names. For example, speech-denoise-32ms.v1.0.rapidly is a model designed to denoise speech with a latency of 32 ms. The micro variant (e.g. speech-denoise-micro-32ms.v1.0.rapidly) is a compact build for CPU-constrained scenarios.
Models within a family (for example, speech-denoise) share characteristics. For general denoising, start with speech-denoise-96ms.v1.0.rapidly and move to shorter latencies if needed.
For specific requirements or challenging audio, we can train custom models. Contact us to discuss options.