Revoize SDK Rust API Reference
This page documents the public Rust API. You’ll use the config::models helpers to get parameters by name, then init and process to run enhancement.
ModelParams Struct
Model parameters for a given model. Obtain these via config::models::get_params(name); don’t construct them manually.
pub struct ModelParams {
/// Input chunk size in samples (use this length for each `process()` call).
pub input_chunk_size_samples: usize,
/// Output chunk size in samples (each `process()` returns this many samples).
pub output_chunk_size_samples: usize,
/// Input sample rate in Hz (e.g. 48000, 16000 for some models).
pub input_sample_rate: usize,
/// Output sample rate in Hz (may differ from input for bandwidth-extension models).
pub output_sample_rate: usize,
}
impl ModelParams {
/// Model name (e.g. "Capella", "Octantis", "Hadar") for display or logging.
pub fn model_name(&self) -> &'static str;
}config::models Module
list_names Function
pub fn list_names() -> Vec<String>Returns the list of available model names for this build (e.g. "Capella", "Octantis", "Hadar"). Only models enabled via Cargo features are included.
Example
use revoize_sdk::config::models;
let names = models::list_names();
for name in &names {
println!("Available model: {}", name);
}get_params Function
pub fn get_params(name: &str) -> Option<ModelParams>Returns model parameters for the given name. Case-sensitive. Returns None if the name is unknown or the model is not available in this build.
Example
use revoize_sdk::config::models;
let params = models::get_params("Capella").expect("Capella not available in this build");
let chunk_size = params.input_chunk_size_samples; // e.g. 480
let sample_rate = params.input_sample_rate; // e.g. 48000init Function
Signature
pub fn init(params: &ModelParams) -> Result<(), Box<dyn std::error::Error>>Initializes the SDK with the given model parameters. Call once before any process() call. Parameters must come from config::models::get_params(name).
Parameters
params– Model parameters fromconfig::models::get_params("Capella")(or another name fromlist_names()).
Returns
Ok(())if initialization succeeds.Errif initialization fails (e.g. session creation, state setup, or missing model data).
Example
use revoize_sdk::{config::models, init};
let params = models::get_params("Capella").ok_or("Model not supported")?;
init(¶ms).expect("Failed to initialize Revoize SDK");process Function
Signature
pub fn process(audio_chunk: &[f32]) -> Result<Vec<f32>, Box<dyn std::error::Error>>Processes one chunk of input audio and returns the enhanced chunk.
WARNING
- Call
init()before using this function. - The length of
audio_chunkmust equal exactly theinput_chunk_size_samplesof theModelParamsused ininit()(e.g. 480 for Capella). - Input sample rate must match the model (see
params.input_sample_rate). Output length will beparams.output_chunk_size_samples.
Parameters
audio_chunk– Slice off32single-channel audio. Length must match the initialized model’sinput_chunk_size_samples.
Returns
- On success:
Vec<f32>of enhanced samples (length =output_chunk_size_samplesof the model). - On error: e.g. SDK not initialized, or chunk size mismatch.
Example
use revoize_sdk::{config::models, init, process};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let params = models::get_params("Capella").ok_or("Model not supported")?;
init(¶ms)?;
let audio_chunk = vec![0.0_f32; params.input_chunk_size_samples];
let enhanced = process(&audio_chunk)?;
assert_eq!(enhanced.len(), params.output_chunk_size_samples);
println!("Enhanced audio has {} samples", enhanced.len());
Ok(())
}