scribble 0.5.4

High-level Rust API for audio transcription using Whisper
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use anyhow::{Context, Result};
use whisper_rs::{WhisperContext, WhisperContextParameters};

use super::logging::init_whisper_logging;

/// Load a Whisper model and return an initialized `WhisperContext`.
pub fn get_context(model_path: &str) -> Result<WhisperContext> {
    init_whisper_logging();

    let ctx_params = WhisperContextParameters::default();
    let ctx = WhisperContext::new_with_params(model_path, ctx_params)
        .with_context(|| format!("failed to load model from path: {model_path}"))?;

    Ok(ctx)
}