Skip to main content

Crate crispasr

Crate crispasr 

Source
Expand description

Safe Rust wrapper for CrispASR speech recognition.

§Quick start

use crispasr::Session;

let sess = Session::open("model.gguf").unwrap();
let pcm = vec![0.0f32; 16000]; // 1s of silence
let segments = sess.transcribe(&pcm).unwrap();
for seg in &segments {
    println!("[{:.1}s - {:.1}s] {}", seg.start, seg.end, seg.text);
}

Structs§

AlignedWord
ChatGenerateOptions
Per-call sampler options for the *_with_options generate entry points.
ChatMessage
One turn in a conversation.
ChatOptions
Per-session open options for ChatSession::open_with_options.
ChatSession
A chat / LLM session over a GGUF model.
CrispASRDeprecated
A loaded CrispASR model (whisper-only, legacy API).
CtcLogits
Per-frame CTC logits captured from a CTC backend.
DiarizeOptions
Construct via Default and set fields as needed — the struct grows alongside the append-only C ABI (#332).
DiarizeSegment
One ASR segment passed to diarize_segments. Caller fills t0 / t1 (seconds) from the upstream transcribe result; the diarizer writes the zero-based speaker index into speaker (-1 means the method had no info to pick).
DiarizeTurn
A speaker turn the diarizer derived from the AUDIO, independent of the caller’s segment grid (#395).
KokoroResolved
Result of kokoro_resolve_for_lang. Mirrors the Python wrapper’s KokoroResolved dataclass.
LidResult
Mic
Library-level microphone handle. The user-supplied callback is invoked from miniaudio’s audio thread with mono float32 PCM in [-1, 1]. Keep the callback short and non-blocking — for ASR, queue the audio and feed Stream::feed from another thread.
Parakeet
Direct Parakeet ASR context with word- and token-level timestamps.
ParakeetResult
Parakeet transcription result with word and token accessors.
PuncModel
BERT-based punctuation restoration model (FireRedPunc).
PyannoteCache
Pre-computed pyannote-seg posteriors over a full audio buffer.
RegistryArtifact
One file in a backend’s canonical default download bundle.
RegistryBundle
The exact artifact bundle downloaded by -m auto.
RegistryEntry
Known-model registry entry.
Segment
A transcription segment with timing information.
Session
SessionSegment
A segment of a unified-session transcription.
SessionWord
Word-level timing (populated by backends that produce it).
SpeakerDB
Speaker database wrapper.
SpeakerEmbedder
Pluggable speaker-embedding model. Wraps the crispasr_speaker_embedder_*_abi family in a safe Rust struct.
Stem
A loaded session over a CrispASR model of any backend. One stem from Session::separate: its name (vocals, drums, …) and its interleaved-stereo PCM at Session::separate_sample_rate.
Stream
Streaming-decoder handle returned by Session::stream_open. Feed PCM with Stream::feed, pull text with Stream::get_text, finalize with Stream::flush. Auto-closes on drop.
StreamingUpdate
One commit from a streaming session — the latest concatenated text plus its absolute audio-time bounds.
TextLidResult
Result of text_detect_language. Label format depends on the loaded GGUF: CLD3 returns ISO 639-1 ("en", "de", "zh-Latn") across 109 labels; GlotLID-V3 / LID-176 fastText return ISO 639-3 with a script tag ("eng_Latn", "sco_Latn") across 2102 or 176 labels respectively. Callers needing ISO 639-1 normalisation must do it on their side — the dispatcher preserves the model’s native space because the script tag carries real information (e.g. zh-Latnzh-Hans).
TranscribeOptions
Options for transcribe_pcm_with_options. Leave defaults for standard Whisper behaviour; set vad: true + vad_model_path for built-in Silero VAD, or tdrz: true with a .en.tdrz model for speaker-turn markers.
VadOptions
Tunables for Session::transcribe_vad. Defaults mirror crispasr’s whisper_vad_default_params plus the max-chunk fallback the shared library uses to bound encoder cost on long audio.

Enums§

ChatError
Why a chat call failed.
DiarizeMethod
Mirrors the append-only CrispasrDiarizeMethod C enum, so new methods may appear in minor releases — match with a _ arm (#332).
LidMethod
Mirrors the append-only C LID-method enum, so new methods may appear in minor releases — match with a _ arm (#332).
RegistryArtifactKind
Role of one artifact in a canonical model download bundle.

Functions§

agglomerative_cluster
Agglomerative single-linkage cosine clustering on L2-normalized speaker embeddings.
align_words
Run CTC / forced-aligner word timings for a transcript + audio pair.
cache_dir
Return the CrispASR cache directory (creating it if missing).
cache_ensure_file
Download filename from url into the CrispASR cache — or return the cached path if already present. Pass None for cache_dir_override to use the platform default.
detect_language_pcm
Run language identification on a 16 kHz mono float PCM buffer.
diarize_segments
Assign a speaker index to each of segs, mutating each DiarizeSegment::speaker in place.
diarize_segments_with_turns
Same as diarize_segments, and additionally returns the speaker turns the method derived from the audio (#395).
enhance_audio_rnnoise
RNNoise audio enhancement on 48 kHz mono PCM.
kokoro_lang_has_native_voice
Whether lang has a native Kokoro voice.
kokoro_lang_is_german
Whether lang is German (Kokoro phoneme selection).
kokoro_resolve_for_lang
Resolve the kokoro model + fallback voice for lang. Mirrors what the CLI does for --backend kokoro -l <lang> (PLAN #56 opt 2b).
lcs_dedup_prefix_count
Chunk-boundary LCS dedup: returns the number of leading tokens of curr_tokens to drop to remove overlap with prev_tail_tokens.
list_known_models
Look up the canonical GGUF for a backend (whisper, parakeet, canary, voxtral, voxtral4b, granite, granite-4.1, qwen3, cohere, wav2vec2). Returns None on miss. List every backend name in the registry, in declaration order.
mic_default_device_name
Human-readable name of the default capture device, or empty string if no input device is available.
registry_default_bundle
Return the backend’s exact canonical -m auto artifact bundle.
registry_lookup
registry_lookup_by_filename
Look up by filename (exact match, then fuzzy substring).
text_detect_language
Detect the language of a UTF-8 text string via the internal text_lid_dispatch (peek the GGUF’s general.architecture → route to CLD3 or fastText).
titanet_cosine_sim
TitaNet cosine similarity between two embeddings.
vad_segments
Run standalone VAD returning speech spans in centiseconds.
vad_slices
Run unified VAD dispatcher returning speech spans in seconds.