Skip to content

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.

rust
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

rust
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

rust
use revoize_sdk::config::models;

let names = models::list_names();
for name in &names {
    println!("Available model: {}", name);
}

get_params Function

rust
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

rust
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. 48000

init Function

Signature

rust
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 from config::models::get_params("Capella") (or another name from list_names()).

Returns

  • Ok(()) if initialization succeeds.
  • Err if initialization fails (e.g. session creation, state setup, or missing model data).

Example

rust
use revoize_sdk::{config::models, init};

let params = models::get_params("Capella").ok_or("Model not supported")?;
init(&params).expect("Failed to initialize Revoize SDK");

process Function

Signature

rust
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_chunk must equal exactly the input_chunk_size_samples of the ModelParams used in init() (e.g. 480 for Capella).
  • Input sample rate must match the model (see params.input_sample_rate). Output length will be params.output_chunk_size_samples.

Parameters

  • audio_chunk – Slice of f32 single-channel audio. Length must match the initialized model’s input_chunk_size_samples.

Returns

  • On success: Vec<f32> of enhanced samples (length = output_chunk_size_samples of the model).
  • On error: e.g. SDK not initialized, or chunk size mismatch.

Example

rust
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(&params)?;

    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(())
}