#whisper #transcription #ai

rwhisper

A simple interface for Whisper transcription models in Rust

5 releases

0.2.1 Feb 28, 2024
0.2.0 Feb 18, 2024
0.1.2 Dec 21, 2023
0.1.1 Dec 21, 2023
0.1.0 Dec 16, 2023

#415 in Audio


Used in 2 crates (via kalosm-sound)

MIT/Apache and LGPL-3.0

355KB
1K SLoC

rwhisper

A Rust wrapper for whisper

Usage

use futures_util::StreamExt;
use rwhisper::*;
use tokio::time::{Duration, Instant};

#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
    // Create a new small whisper model.
    let model = WhisperBuilder::default()
        .with_source(WhisperSource::SmallEn)
        .build()?;

    // Record audio from the microphone for 5 seconds.
    let audio = kalosm_sound::MicInput::default()
        .record_until(Instant::now() + Duration::from_secs(5))
        .await?;

    // Transcribe the audio.
    let mut text = model.transcribe(audio)?;

    // As the model transcribes the audio, print the text to the console.
    while let Some(text) = text.next().await {
        print!("{}", text.text());
    }

    Ok(())
}

Dependencies

~27–67MB
~1M SLoC