Skip to content

Rust API Reference

ModelType Enum

The ModelType enum defines the AI models available in the Revoize SDK:

rust
#[derive(Debug)]
pub enum ModelType {
    /// Capella: A lightweight model optimized for efficiency.
    Capella,
    /// Algol: A generative model with advanced capabilities.
    Algol,
}

init Function

Signature

rust
pub fn init(model_type: ModelType) -> Result<(), Box<dyn Error>>

The init function is your starting point for using the Revoize SDK. It sets up the SDK with the specified model type. Note: Make sure to call this function before any other SDK functions to ensure everything is properly set up.

Parameters

  • model_type The model type to initialize the SDK with. Choose from the ModelType enum variants (e.g., ModelType::Capella or ModelType::Algol).

Returns

A Result indicating success or failure:

  • Ok(()) if initialization is successful.
  • Err if an error occurs during initialization (e.g., session creation, state setup, or missing model constants).

Errors

An error is returned if initialization fails at any step.

Example

rust
use revoize_sdk::init;
use revoize_sdk::ModelType;

fn main() {
    // Initialize the SDK with the Capella model.
    init(ModelType::Capella).expect("Failed to initialize Revoize SDK");
}

process Function

Signature

rust
pub fn process(audio_chunk: &[f32]) -> Result<Vec<f32>, Box<dyn Error>>

The process function takes an input audio chunk and returns the enhanced chunk.

WARNING

  • Ensure init() is called before using this function.
  • The audio_chunk should be from a 48 kHz recording.

Parameters

  • audio_chunk A slice of f32 representing single-channel audio samples from a 48 kHz recording.

Returns

  • Result<Vec<f32>, Box<dyn std::error::Error>> On success, returns a vector of enhanced audio samples. Otherwise, returns an error if processing fails (e.g., if the SDK hasn't been initialized).

Example

rust
use revoize_sdk::{init, process};
use revoize_sdk::ModelType;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialize the SDK before processing audio.
    init(ModelType::Capella)?;

    // Prepare an audio chunk from a 48 kHz recording.
    let audio_chunk = vec![1.0_f32; 480 * 10]; // 10 frames of 480 samples each
    let enhanced_audio = process(&audio_chunk)?;

    println!("Enhanced audio has {} samples", enhanced_audio.len());
    Ok(())
}