Skip to main content

Crate crispasr_sys

Crate crispasr_sys 

Source
Expand description

Raw FFI bindings to CrispASR. Mirrors the public C API in include/crispasr.h and include/crispasr_session.h.

Structs§

CrispasrAlignResult
Opaque result handle for crispasr_align_words_abi. Must be freed with crispasr_align_result_free.
CrispasrChatError
Out-parameter for every chat entry point that can fail (may be null). Left untouched on success; on failure code is non-zero and message holds a NUL-terminated diagnostic.
CrispasrChatGenerateParams
Per-call, sampler-level generate params. Fill via crispasr_chat_generate_params_default before overriding fields.
CrispasrChatMessage
One turn of a conversation. role is “system”, “user”, “assistant” or “tool”; both pointers must stay valid for the duration of the call.
CrispasrChatOpenParams
Per-session, model-level open params. Fill via crispasr_chat_open_params_default before overriding fields — the C side reads every one of them.
CrispasrChatSession
Opaque handle returned by crispasr_chat_open. Free with crispasr_chat_close.
CrispasrDiarizeOptsAbi
ABI options for crispasr_diarize_segments_abi. method is a value in 0..4: 0 = Energy, 1 = Xcorr, 2 = VadTurns, 3 = Pyannote, 4 = FoxNose. pyannote_model_path is required for Pyannote, foxnose_embedder_path for FoxNose; each is ignored otherwise.
CrispasrDiarizeSegAbi
ABI segment for crispasr_diarize_segments_abi. Caller fills t0_cs / t1_cs; the diarizer writes speaker (-1 if unassigned).
CrispasrDiarizeTurnAbi
ABI speaker turn for crispasr_diarize_segments_turns_abi (#395).
CrispasrMic
Opaque microphone handle returned by crispasr_mic_open. Must be freed with crispasr_mic_close. (PLAN #62d)
CrispasrSession
Opaque handle returned by crispasr_session_open.
CrispasrSessionResult
Opaque result handle returned by crispasr_session_transcribe. Must be freed with crispasr_session_result_free.
CrispasrStream
Opaque streaming-decoder handle returned by crispasr_session_stream_open. Must be freed with crispasr_stream_close. (PLAN #62)
CrispasrUltraAlignResult
Opaque experimental Ultra local-head alignment result. Must be freed with crispasr_ultra_align_result_free.
CrispasrVadAbiOpts
Tunables for crispasr_session_transcribe_vad. Mirrors crispasr’s whisper_vad_params plus the max-chunk fallback used to bound encoder cost on long audio. Pass a null pointer to use defaults.
WhisperContext
Opaque context handle.
WhisperContextParams
Opaque context params handle.
WhisperFullParams
Opaque params handle (allocated by whisper_full_default_params_by_ref).
WhisperState
Opaque state handle.

Constants§

CRISPASR_AHEADS_BASE
CRISPASR_AHEADS_BASE_EN
CRISPASR_AHEADS_CUSTOM
CRISPASR_AHEADS_LARGE_V1
CRISPASR_AHEADS_LARGE_V2
CRISPASR_AHEADS_LARGE_V3
CRISPASR_AHEADS_LARGE_V3_TURBO
CRISPASR_AHEADS_MEDIUM
CRISPASR_AHEADS_MEDIUM_EN
CRISPASR_AHEADS_NONE
Built-in Whisper DTW alignment-head presets (public C enum values).
CRISPASR_AHEADS_N_TOP_MOST
CRISPASR_AHEADS_SMALL
CRISPASR_AHEADS_SMALL_EN
CRISPASR_AHEADS_TINY
CRISPASR_AHEADS_TINY_EN
CRISPASR_CHAT_ERR_ABORTED
The one error code on the chat ABI with a stable, documented meaning: a registered abort callback stopped the run. Every other non-zero CrispasrChatError::code is a diagnostic aid — read message.
CRISPASR_SAMPLING_BEAM_SEARCH
CRISPASR_SAMPLING_GREEDY
Sampling strategy.

Functions§

crispasr_align_result_character_t0⚠
crispasr_align_result_character_t1⚠
crispasr_align_result_character_text⚠
crispasr_align_result_free⚠
crispasr_align_result_n_characters⚠
crispasr_align_result_n_words⚠
crispasr_align_result_word_t0⚠
crispasr_align_result_word_t1⚠
crispasr_align_result_word_text⚠
crispasr_align_words_abi⚠
Shared CTC / forced-aligner word timings (0.4.7+). Pass any aligner_model path — filenames containing “forced-aligner” / “qwen3-fa” / “qwen3-forced” go through the Qwen3-ForcedAligner path; everything else uses canary-ctc. Returns a handle the caller must free with crispasr_align_result_free. Returns null on failure.
crispasr_align_words_ultra_abi⚠
Experimental Ultra alignment with a separate local-head GGUF. Audio is mono 16 kHz, at most 120 seconds. Null means failure. Returned word times are milliseconds, including fractional milliseconds.
crispasr_audio_free⚠
crispasr_audio_load⚠
crispasr_audio_load_at_rate⚠
crispasr_audio_load_stereo⚠
crispasr_audio_resample⚠
crispasr_backend_caps_abi⚠
crispasr_backend_caps_list_abi⚠
crispasr_c2pa_free⚠
crispasr_c2pa_sign⚠
crispasr_c_api_version⚠
crispasr_cache_dir_abi⚠
Return the CrispASR cache directory (creating it if missing).
crispasr_cache_ensure_file_abi⚠
Shared HF download + cache (0.4.8+). Writes the resolved path into out_buf. Returns 0 on success, -1 on invalid args, 1 on download failure, 2 when the output buffer is too small.
crispasr_chat_ai_disclosure_text⚠
Canonical EU AI Act Art. 50(1) “you are talking to an AI” wording. Static string — never null, never freed.
crispasr_chat_close⚠
crispasr_chat_count_tokens⚠
Prompt tokens a FRESH session prefills for messages — chat template, BOS, and the trailing generation prompt included. Negative on failure, with err filled.
crispasr_chat_generate⚠
Returns a malloc’d UTF-8 string (free with crispasr_chat_string_free) or null on failure / abort.
crispasr_chat_generate_params_default⚠
crispasr_chat_generate_stream⚠
0 on clean completion (including stop-sequence / EOG termination), CRISPASR_CHAT_ERR_ABORTED when the abort callback stopped it, other non-zero on failure.
crispasr_chat_memory_estimate⚠
Approximate working set in bytes for a GGUF chat model on disk, or 0 when it could not be estimated (err filled).
crispasr_chat_n_ctx⚠
crispasr_chat_open⚠
crispasr_chat_open_params_default⚠
crispasr_chat_reset⚠
crispasr_chat_set_abort_callback⚠
Register cb on the session (null clears it). Takes the session lock, so calling it during a generation blocks rather than cancelling — register before starting one.
crispasr_chat_string_free⚠
crispasr_chat_template_name⚠
crispasr_ctx_params_set_dtw⚠
crispasr_dart_helpers_version⚠
crispasr_detect_backend_from_gguf⚠
crispasr_detect_backends_from_gguf⚠
crispasr_detect_language⚠
crispasr_detect_language_pcm⚠
Shared language identification (0.4.6+). method is 0 for whisper, 1 for silero. model_path is required. Fills out_lang_buf with a null-terminated ISO 639-1 code. Returns 0 on success, -1 on invalid args, 1 on model / detect failure, 2 when the output buffer is too small.
crispasr_diarize_segments_abi⚠
Shared speaker diarization (0.4.5+). Writes a zero-based speaker index into each segs[i].speaker. Returns 0 on success, 1 on Pyannote model load failure, -1 on invalid args.
crispasr_diarize_segments_turns_abi⚠
Diarize AND hand back the speaker turns the method derived from the audio (0.8.30+, issue #395). Identical to crispasr_diarize_segments_abi plus the three trailing turn parameters; passing null / 0 / null for them is exactly the older call.
crispasr_drain_streamed_segments⚠
crispasr_drain_streamed_tokens⚠
crispasr_enhance_audio_rnnoise⚠
crispasr_free_aligner_cache⚠
crispasr_get_progress⚠
crispasr_get_streamed_segment_count⚠
crispasr_get_streamed_token_count⚠
crispasr_kokoro_lang_has_native_voice_abi⚠
crispasr_kokoro_lang_is_german_abi⚠
crispasr_kokoro_resolve_fallback_voice_abi⚠
crispasr_kokoro_resolve_model_for_lang_abi⚠
crispasr_lcs_dedup_prefix_count⚠
crispasr_mic_close⚠
crispasr_mic_default_device_name⚠
crispasr_mic_open⚠
crispasr_mic_start⚠
crispasr_mic_stop⚠
crispasr_parakeet_free⚠
crispasr_parakeet_init⚠
crispasr_parakeet_result_free⚠
crispasr_parakeet_result_n_tokens⚠
crispasr_parakeet_result_n_words⚠
crispasr_parakeet_result_text⚠
crispasr_parakeet_result_token_p⚠
crispasr_parakeet_result_token_t0⚠
crispasr_parakeet_result_token_t1⚠
crispasr_parakeet_result_token_text⚠
crispasr_parakeet_result_word_t0⚠
crispasr_parakeet_result_word_t1⚠
crispasr_parakeet_result_word_text⚠
crispasr_parakeet_transcribe⚠
crispasr_params_set_alt_n⚠
crispasr_params_set_best_of⚠
crispasr_params_set_detect_language⚠
crispasr_params_set_initial_prompt⚠
crispasr_params_set_language⚠
crispasr_params_set_max_len⚠
crispasr_params_set_max_tokens⚠
crispasr_params_set_n_threads⚠
crispasr_params_set_no_context⚠
crispasr_params_set_print_progress⚠
crispasr_params_set_print_realtime⚠
crispasr_params_set_print_special⚠
crispasr_params_set_print_timestamps⚠
crispasr_params_set_single_segment⚠
crispasr_params_set_split_on_word⚠
crispasr_params_set_suppress_blank⚠
crispasr_params_set_tdrz⚠
crispasr_params_set_temperature⚠
crispasr_params_set_token_timestamps⚠
crispasr_params_set_translate⚠
crispasr_params_set_vad⚠
crispasr_params_set_vad_min_silence_ms⚠
crispasr_params_set_vad_min_speech_ms⚠
crispasr_params_set_vad_model_path⚠
crispasr_params_set_vad_threshold⚠
crispasr_pcm_free⚠
crispasr_pcm_to_wav⚠
crispasr_pcs_free⚠
crispasr_pcs_free_text⚠
crispasr_pcs_init⚠
crispasr_pcs_process⚠
crispasr_punc_free⚠
crispasr_punc_free_text⚠
crispasr_punc_init⚠
crispasr_punc_process⚠
crispasr_pyannote_cache_apply_abi⚠
Score segs against the cached posteriors. slice_t0_cs is the absolute centisecond at which the cache buffer starts (typically 0 — the cache covers the whole input audio).
crispasr_pyannote_cache_compute_abi⚠
Pre-compute pyannote-seg posteriors over a full audio buffer. Returns an opaque cache or null on failure. Free with crispasr_pyannote_cache_free_abi.
crispasr_pyannote_cache_free_abi⚠
crispasr_registry_default_bundle_artifact_abi⚠
Read one default-bundle artifact by index. 0 = success.
crispasr_registry_default_bundle_info_abi⚠
Describe the exact canonical artifact bundle downloaded by -m auto. Returns its artifact count, 0 on miss, or a negative argument/buffer error.
crispasr_registry_list_backends_abi⚠
Shared known-model registry lookup by filename (exact then fuzzy).
crispasr_registry_lookup_abi⚠
Shared known-model registry lookup by backend. 0 = hit, 1 = miss.
crispasr_registry_lookup_by_filename_abi⚠
crispasr_reset_progress⚠
crispasr_reset_streamed_segments⚠
crispasr_reset_streamed_tokens⚠
crispasr_session_accept_marking_responsibility⚠
crispasr_session_available_backends⚠
Write a comma-separated list of backend names the loaded dylib was built with. Returns the number of bytes written (not counting NUL) or a negative error.
crispasr_session_backend⚠
crispasr_session_beats⚠
crispasr_session_beats_events⚠
crispasr_session_beats_n_events⚠
crispasr_session_beats_sample_rate⚠
crispasr_session_beats_tempo_bpm⚠
crispasr_session_chords⚠
crispasr_session_chords_n_spans⚠
crispasr_session_chords_span_name⚠
crispasr_session_chords_spans⚠
crispasr_session_chords_vocab_size⚠
crispasr_session_close⚠
crispasr_session_convert⚠
crispasr_session_convert_audio⚠
crispasr_session_convert_content_dim⚠
crispasr_session_convert_inter_channels⚠
crispasr_session_convert_n_speakers⚠
crispasr_session_convert_sample_rate⚠
crispasr_session_convert_upsample_product⚠
crispasr_session_detect_language⚠
crispasr_session_detected_language⚠
crispasr_session_disclaimer_text⚠
crispasr_session_get_disclaimer_pcm⚠
crispasr_session_get_speaker_name⚠
crispasr_session_input_channels⚠
crispasr_session_input_sample_rate⚠
crispasr_session_is_custom_voice⚠
crispasr_session_is_voice_design⚠
crispasr_session_kokoro_clear_phoneme_cache⚠
crispasr_session_last_synth_error⚠
crispasr_session_n_speakers⚠
crispasr_session_n_vocab⚠
crispasr_session_open⚠
crispasr_session_open_explicit⚠
crispasr_session_open_with_params⚠
crispasr_session_output_channels⚠
crispasr_session_output_sample_rate⚠
crispasr_session_piano⚠
crispasr_session_piano_n_notes⚠
crispasr_session_piano_note_programs⚠
crispasr_session_piano_notes⚠
crispasr_session_piano_sample_rate⚠
crispasr_session_pitch⚠
crispasr_session_pitch_frame⚠
crispasr_session_pitch_frames⚠
crispasr_session_pitch_n_frames⚠
crispasr_session_pitch_sample_rate⚠
crispasr_session_result_free⚠
crispasr_session_result_logits⚠
crispasr_session_result_n_logit_frames⚠
crispasr_session_result_n_logit_vocab⚠
crispasr_session_result_n_segments⚠
crispasr_session_result_n_tokens⚠
crispasr_session_result_n_words⚠
crispasr_session_result_segment_no_speech_prob⚠
crispasr_session_result_segment_speaker⚠
crispasr_session_result_segment_t0⚠
crispasr_session_result_segment_t1⚠
crispasr_session_result_segment_text⚠
crispasr_session_result_token_p⚠
crispasr_session_result_token_t0⚠
crispasr_session_result_token_t1⚠
crispasr_session_result_token_text⚠
crispasr_session_result_word_alt_p⚠
crispasr_session_result_word_alt_text⚠
crispasr_session_result_word_n_alts⚠
crispasr_session_result_word_p⚠
crispasr_session_result_word_t0⚠
crispasr_session_result_word_t1⚠
crispasr_session_result_word_text⚠
crispasr_session_score_texts⚠
crispasr_session_separate⚠
crispasr_session_separate_n_stems⚠
crispasr_session_separate_sample_rate⚠
crispasr_session_separate_stem⚠
crispasr_session_separate_stem_name⚠
crispasr_session_set_alt_n⚠
crispasr_session_set_ask⚠
crispasr_session_set_audio_ctx⚠
crispasr_session_set_autochunk⚠
crispasr_session_set_beam_size⚠
crispasr_session_set_best_of⚠
crispasr_session_set_cfg_weight⚠
crispasr_session_set_codec_path⚠
crispasr_session_set_do_sample⚠
crispasr_session_set_exaggeration⚠
crispasr_session_set_fallback_thresholds⚠
crispasr_session_set_frequency_penalty⚠
crispasr_session_set_g2p_dict⚠
crispasr_session_set_grammar_strict⚠
crispasr_session_set_grammar_text⚠
crispasr_session_set_hikari_refresh_stride⚠
crispasr_session_set_hotwords⚠
crispasr_session_set_instruct⚠
crispasr_session_set_length_scale⚠
crispasr_session_set_max_new_tokens⚠
crispasr_session_set_max_new_tokens_per_second⚠
crispasr_session_set_max_speech_tokens⚠
crispasr_session_set_min_p⚠
crispasr_session_set_min_speech_tokens⚠
crispasr_session_set_parakeet_att_context⚠
crispasr_session_set_pcm_sample_rate⚠
crispasr_session_set_progress_callback⚠
0.10.3+ (issue #208): register a per-session progress callback for long-form (chunked) transcription. Fired once per finished window with (processed_samples, total_samples, user_data); processed is monotonic and reaches total on the last window. Invoked on the transcribe thread. Pass None/null cb to clear.
crispasr_session_set_punc_model⚠
crispasr_session_set_punctuation⚠
crispasr_session_set_repetition_penalty⚠
crispasr_session_set_return_logits⚠
crispasr_session_set_segment_callback⚠
crispasr_session_set_sensitivity⚠
crispasr_session_set_source_language⚠
crispasr_session_set_speaker_id⚠
crispasr_session_set_speaker_identity⚠
crispasr_session_set_speaker_name⚠
crispasr_session_set_target_language⚠
crispasr_session_set_temperature⚠
crispasr_session_set_token_callback⚠
crispasr_session_set_top_k⚠
crispasr_session_set_top_p⚠
crispasr_session_set_translate⚠
crispasr_session_set_tts_cfg_scale⚠
crispasr_session_set_tts_noise_temp⚠
crispasr_session_set_tts_num_candidates⚠
crispasr_session_set_tts_pad_silence_ms⚠
crispasr_session_set_tts_phonemes⚠
crispasr_session_set_tts_reference_language⚠
crispasr_session_set_tts_seed⚠
crispasr_session_set_tts_steps⚠
crispasr_session_set_voice⚠
crispasr_session_set_voice_samples⚠
crispasr_session_set_whisper_decode_extras⚠
crispasr_session_speech_to_speech⚠
crispasr_session_stream_kind⚠
crispasr_session_stream_open⚠
crispasr_session_synthesize⚠
crispasr_session_synthesize_raw⚠
crispasr_session_synthesize_streaming⚠
crispasr_session_tab⚠
crispasr_session_tab_emissions⚠
crispasr_session_tab_frame_period⚠
crispasr_session_tab_n_frames⚠
crispasr_session_tab_silent_class⚠
crispasr_session_tab_string_open_midi⚠
crispasr_session_tada_set_makeref_models⚠
crispasr_session_token_text⚠
crispasr_session_transcribe⚠
crispasr_session_transcribe_chunked⚠
crispasr_session_transcribe_chunked_lang⚠
0.8.7+: chunked-encode transcribe (issue #208). Forces the Parakeet backend through its bounded long-form path (overlapping short-window transcribe-and-merge for non-JA models, streamed encoder for the JA-only model) regardless of audio length, so long files transcribe in bounded time AND recover the sections a single full-length pass drops. chunk_seconds <= 0 keeps the per-model defaults; otherwise it sets the non-JA window length / the JA streamed window. overlap_seconds < 0 uses the default. For non-Parakeet backends the chunk params are inert and this matches crispasr_session_transcribe_lang.
crispasr_session_transcribe_lang⚠
0.4.9+: language-aware session transcribe. language is an ISO 639-1 code or null/empty to keep the backend’s historical default. Backends that accept a source-language hint (whisper, canary, cohere, voxtral, voxtral4b) honour it; others ignore silently.
crispasr_session_transcribe_vad⚠
VAD-driven session transcribe. Runs Silero VAD on the PCM buffer, merges short / overlong speech slices, stitches them into one contiguous buffer with 0.1s silence gaps, calls the backend once, then remaps segment + word timestamps back to original-audio positions.
crispasr_session_transcribe_vad_lang⚠
0.4.9+: language-aware VAD transcribe (same semantics as the language kwarg on crispasr_session_transcribe_lang).
crispasr_session_translate_text⚠
crispasr_session_translate_text_free⚠
crispasr_set_gpu_backend⚠
crispasr_speaker_cluster_abi⚠
Agglomerative single-linkage cosine clustering. embeddings is a row-major n × dim buffer of (ideally L2-normalized) vectors. labels_out receives one cluster ID per input in [0, k). Returns the cluster count k, or -1 on invalid arguments.
crispasr_speaker_db_count⚠
crispasr_speaker_db_enroll⚠
crispasr_speaker_db_enroll2⚠
crispasr_speaker_db_free⚠
crispasr_speaker_db_load⚠
crispasr_speaker_db_match⚠
crispasr_speaker_db_open⚠
crispasr_speaker_embedder_dim_abi⚠
Output embedding dimension (e.g. 192 for TitaNet, 512 for IndexTTS-BigVGAN).
crispasr_speaker_embedder_embed_abi⚠
Extract one embedding. out must hold at least dim() floats. Returns 1 on success, 0 if the model rejected the input.
crispasr_speaker_embedder_free_abi⚠
crispasr_speaker_embedder_make_abi⚠
Build a pluggable speaker embedder. model_spec is one of "auto", "titanet", "indextts", "indextts-bigvgan", "ecapa", or a .gguf path. Returns null on failure.
crispasr_speaker_embedder_name_abi⚠
crispasr_stream_close⚠
crispasr_stream_feed⚠
crispasr_stream_flush⚠
crispasr_stream_get_text⚠
crispasr_stream_open⚠
crispasr_stream_set_live_decode⚠
Toggle voxtral4b live-captions decode-during-feed (PLAN #7 phase 3). No-op for backends that don’t have audio-injection prompt decode. Set BEFORE the first feed for clean semantics.
crispasr_text_detect_language⚠
crispasr_titanet_cosine_sim⚠
crispasr_titanet_embed⚠
crispasr_titanet_free⚠
crispasr_titanet_init⚠
crispasr_token_alt_id⚠
crispasr_token_alt_p⚠
crispasr_token_alt_text⚠
crispasr_token_dtw_t⚠
crispasr_token_n_alts⚠
crispasr_token_p⚠
crispasr_token_t0⚠
crispasr_token_t1⚠
crispasr_transcribe_parallel_by_ref⚠
Pointer-parameter parallel decode with native progress tracking.
crispasr_truecase_free⚠
crispasr_truecase_free_text⚠
crispasr_truecase_init⚠
crispasr_truecase_process⚠
crispasr_ultra_align_result_free⚠
crispasr_ultra_align_result_n_words⚠
crispasr_ultra_align_result_word_end_ms⚠
crispasr_ultra_align_result_word_start_ms⚠
crispasr_ultra_align_result_word_text⚠
crispasr_vad_free⚠
crispasr_vad_segments⚠
crispasr_vad_slices⚠
crispasr_watermark_detect⚠
crispasr_watermark_embed⚠
crispasr_watermark_load_model⚠
whisper_context_default_params_by_ref⚠
whisper_free⚠
whisper_free_context_params⚠
whisper_free_params⚠
whisper_full⚠
whisper_full_default_params_by_ref⚠
whisper_full_get_segment_no_speech_prob⚠
whisper_full_get_segment_t0⚠
whisper_full_get_segment_t1⚠
whisper_full_get_segment_text⚠
whisper_full_get_token_id⚠
whisper_full_get_token_text⚠
whisper_full_lang_id⚠
whisper_full_n_segments⚠
whisper_full_n_tokens⚠
whisper_init_from_file_with_params⚠
whisper_lang_id⚠
whisper_lang_str⚠

Type Aliases§

CrispasrChatAbortCallback
Abort hook. Returns true to continue, false to abort — the whisper_encoder_begin_callback convention on the ASR surface, and the opposite of ggml’s own. Called on the generating thread before each prompt batch and each sampled token, and (CPU backend only) from inside a running compute graph, so it must be cheap and non-blocking. It must not re-enter the session that registered it — the session mutex is held.
CrispasrChatOnToken
Fired once per detokenised UTF-8 chunk during a streaming generate. The chunk pointer is valid only for the duration of the call. Option<...> so a null pointer clears the callback (C NULL).
CrispasrProgressCallback
Progress callback for long-form (chunked) transcription (issue #208). Option<...> so a null pointer clears the callback (C NULL).