Skip to main content

Crate native_whisperx

Crate native_whisperx 

Source
Expand description

§native-whisperx

Reusable workflow library for composing moritzbrantner-* transcription, alignment, diarization, and transcript crates into a WhisperX-style pipeline.

This crate owns workflow configuration and output writing. The reusable audio, text, model-runtime, and speaker primitives remain in rust-packages.

§Release Role

native-whisperx is the library crate for Workflow Composition APIs. It is published before native-whisperx-cli. After that manual release order, Cargo users install the CLI package with:

cargo install native-whisperx-cli

The installed terminal command is native-whisperx.

§Workflow Surface

The crate composes native transcription, default wav2vec2 alignment, optional speaker diarization, optional segment-level post-ASR translation, and output writing. The user-facing parity target is the Python WhisperX CLI. Delegated features remain delegated where the repository has not yet replaced them with a Rust-Native Parity path.

Default json output is WhisperX JSON. Use native-json through the CLI when you need the Rust transcript contract shape.

Installing the CLI package does not make transcription resources available. Model bundles, cache entries, CUDA, Python WhisperX compatibility resources, and gated Hugging Face assets are resolved by the invoked workflow. Delegated Feature paths remain delegated until separate Rust-Native Parity work replaces them.

§Feature Flags

FeaturePurpose
nativeNative Candle Whisper and wav2vec2 alignment composition. Enabled by default.
translationHelsinki-NLP OPUS-MT/Marian post-ASR segment translation and the curated planning/runtime surface. Enabled by default.
cudaCUDA-backed Candle execution for hosts with a local CUDA toolchain.
media-decodeFFmpeg-backed finite non-WAV media/container decode through the audio I/O crate. Enabled by default.
diarizationHeuristic speaker diarization composition.
onnx-diarizationExplicit ONNX speaker embedding diarization path.
pyannote-diarizationNative pyannote community diarization bundle path. Enabled by default for Automatic Workflow Selection, with runtime resources resolved lazily.
silero-vadExplicit Silero ONNX VAD path.
pyannote-vadNative pyannote ONNX VAD path. Enabled by default for Automatic Workflow Selection, with runtime resources resolved lazily.
whisperx-compatExternal Python WhisperX command compatibility and parity checks.

Default library and CLI packaging includes translation plus the pyannote VAD and pyannote diarization code paths required by automatic native --diarize. Enabling the translation code does not start translation or resolve a model: TranslationConfig::default() remains disabled, and resources are accessed only when a configured workflow uses them. Default builds do not bundle models or eagerly access Hugging Face credentials, ONNX Runtime dynamic-library configuration, CUDA, Python WhisperX, or parity resources.

Builds using --no-default-features remain supported and translation-free. Minimal embedding applications can explicitly enable only translation or the other feature rows they need.

§Translation Planning and Immutable Results

CuratedLanguage contains English (en), German (de), French (fr), Spanish (es), Italian (it), Portuguese (pt), Dutch (nl), and Polish (pl). TranslationPlan::new and TranslationPlan::from_language_codes choose a deterministic plan for every distinct ordered pair. A validated model pair produces TranslationPlanProvenance::Direct; otherwise the plan records two ordered legs through English as TranslationPlanProvenance::PivotTranslation.

translate_transcription borrows an existing TranscriptionPipelineResponse and returns a separate TranslatedTranscriptionResult. The source response is never mutated, so its text, detected language, segment boundaries, word and character timings, diagnostics, and metadata remain available even when translation fails. The translated result keeps segment timing and ordered model provenance separately; source-language word and character alignments are not copied onto target text. Use translate_transcription_with_control for progress and cooperative cancellation at translation-leg and segment boundaries.

TranslationConfig is a library-owned type, independent from CLI argument types. model_bundle selects an explicit local bundle. model_dir selects an application-owned model/cache root, and model_cache_only is a hard no-download control: missing assets fail model resolution. CLI flags map into this type, but embedding applications configure it directly.

§Finite Media Inputs

Default builds include finite media decode support. WAV files continue to use the native WAV reader path. Non-WAV finite media files route through the FFmpeg-backed media decode path when the required runtime tools are installed.

The guaranteed finite input set is wav, mp3, m4a, aac, flac, ogg, opus, mp4, mov, mkv, and webm. Other FFmpeg-decodable files may work on a best-effort basis, but they are not part of the guaranteed support set. Video files are transcribed from the selected/default audio track only; video frames are not analyzed.

Builds using --no-default-features do not implicitly include finite non-WAV media decode. Enable media-decode explicitly for minimal builds that still need FFmpeg-backed media/container input support.

§Finite Progress and Cancellation

run_with_observer and run_many_with_observer emit the ordered Transcription Progress Stream while preserving their existing non-cancellable return types. Embedding applications that need cooperative cancellation use run_with_control or run_many_with_control with a cloneable CancellationHandle; another thread may call cancel(), and Workflow Composition stops at the next safe phase boundary. Cancellation is a typed outcome and does not emit a generic failure. A cancelled Multi-Input Transcription Run retains completed reports and identifies inputs that were not finished.

TranscriptionProgressEvent is now #[non_exhaustive] because model resolution/download and direct or Pivot Translation leg facts extend the stream. Existing consumers that exhaustively matched the enum must add a wildcard arm. Existing run, run_with_observer, run_many, and run_many_with_observer calls remain available and use an uncancelled control internally.

§Live Progress and Cancellation

LiveTranscriptionProgressObserver receives operational session, Near-Live Window, model resolution/download/load/reuse, completion, failure, and cancellation facts. It is intentionally separate from LiveTranscriptEvent: progress is telemetry, while Live Transcript Events remain the JSONL transcript output contract.

Pass the same cloneable CancellationHandle to LivePcmIngestionSession::ingest_reader_with_control to cancel before the next Near-Live Window. Cancellation retains already stable final events, discards unstable partial text, emits LiveTranscriptionProgressEvent::Cancelled, and ends the transcript stream with LiveSessionEndReason::Cancelled. Existing ingest_reader, ingest_reader_with_event_sink, and ingest_reader_with_observer entry points remain available and use an uncancelled handle internally.

§Exhaustive Enum Migration

Version 0.1.14 adds LiveSessionEndReason::Cancelled; existing exhaustive matches over LiveSessionEndReason must add that arm. The new TranscriptionProgressEvent and LiveTranscriptionProgressEvent contracts are #[non_exhaustive]; downstream matches must include a wildcard arm so future progress facts remain source compatible. Prefer an explicit Cancelled arm before the wildcard when cancellation changes application state.

§Documentation

The canonical public API documentation target is https://docs.rs/native-whisperx. Repository release and model-resource setup details are in https://github.com/moritzbrantner/native-whisperx.

Structs§

AlignmentConfig
AsrConfig
AutomaticWorkflowSelection
AutomaticWorkflowSelectionDecision
CancellationHandle
Cloneable cooperative cancellation shared by finite and live workflows.
DiarizationConfig
ExpectedOutputComparison
ExpectedOutputFile
ExternalWhisperxConfig
FiniteCancellation
Details about the safe finite-workflow boundary where cancellation won.
LiveAsrSegmentCandidate
LiveFinalTranscriptSegment
LivePartialSegment
LivePartialTranscript
LivePcmIngestionReport
LivePcmIngestionSession
LivePcmWindow
LiveSessionEnded
LiveSessionStarted
LiveTranscriptError
LiveWindow
LiveWindowPlanner
LiveWindowProcessingError
LiveWindowState
LiveWindowTranscriptObservation
LiveWindowingConfig
NativeWhisperxConfig
NativeWhisperxReport
NativeWorkflowSelectionReport
NoopLiveTranscriptionProgressObserver
NoopTranscriptionProgressObserver
OutputConfig
OutputFile
ParityComparison
ParityComparisonConfig
ParityConfig
ParityFixtureCase
ParityFixtureCaseReport
ParityFixtureSuite
ParityFixtureSuiteReport
ParityMultiInputFixtureCase
ParityPreflightCaseReport
ParityPreflightReport
ParityReport
ParityTolerance
ResolvedSpeakerDirectory
SelectedDiarizationModelReport
SelectedVadReport
SpeakerCorrectionRange
SpeakerCorrectionReport
SpeakerCorrectionRequest
SpeakerDirectorySelection
SpeakerDirectoryState
SpeakerLibraryState
SpeakerLibraryValidation
SpeakerProfileEdit
SpeakerProfileState
SpeakerProfileSummary
SpeakerTrace
SpeakerTraceError
SpeakerTraceFile
SpeakerTraceRebuildReport
SpeakerTraceRebuildStats
SpeakerTraceSpan
SpeakerTraceSpeaker
SpeakerTraceState
SubtitleConfig
TranscriptSegmentContract
TranscriptionContract
TranscriptionPipelineRequest
Request for an audio/video-to-text transcription pipeline.
TranscriptionPipelineResponse
Response from a transcription pipeline.
TranslatedTranscriptionResult
A translated transcript kept separate from its source pipeline response.
TranslationConfig
Library-owned controls for post-ASR translation model resolution.
TranslationLeg
One ordered OPUS-MT model invocation in a translation plan.
TranslationModelError
A typed failure reported by a SegmentTranslationProvider.
TranslationPlan
A deterministic direct or Pivot Translation plan.
UnfinishedTranscription
Input not completed by a cancelled Multi-Input Transcription Run.
VadConfig
WhisperxDecodeConfig

Enums§

AlignmentInterpolationMethod
Timestamp interpolation behavior for missing alignment spans.
AsrProvider
AssignmentPolicy
AutomaticWorkflowSelectionResource
ConfigSelection
CuratedLanguage
A language supported by the curated native translation registry.
DevicePreference
ExpectedTranscriptTarget
FiniteTranscriptionOutcome
Typed result of a cancellable single-input finite workflow.
InputSource
LiveSessionEndReason
LiveTranscriptEvent
LiveTranscriptionProgressEvent
One ordered progress observation from a Live Feed Transcription session.
LiveWindowingError
ModelResourceSource
MultiInputTranscriptionOutcome
Typed result of a cancellable Multi-Input Transcription Run.
NativeWhisperxError
OutputComparisonMode
OutputFormat
ResolvedSpeakerDirectoryScope
SegmentResolution
SpeakerDirectoryScope
SpeakerDirectoryStateScope
SpeakerLibraryValidationStatus
SpeakerTraceSpeakerKind
SpeakerTraceStateStatus
TranscriptionProgressEvent
One ordered observation in the finite Transcription Progress Stream.
TranscriptionProgressTask
TranscriptionTask
TranslatedTranscriptionOutcome
Typed result of translating an immutable transcription with cooperative control.
TranslationError
A typed failure while executing an already validated translation plan.
TranslationPlanError
Validation failures returned before any translation model is resolved.
TranslationPlanProvenance
Whether a plan uses one direct model or composes two legs through English.
VadMethod

Constants§

GLOBAL_SPEAKER_DIRECTORY_APP
GLOBAL_SPEAKER_DIRECTORY_NAME
LIVE_PCM_SAMPLE_RATE
LOCAL_SPEAKER_DIRECTORY
SPEAKER_LIBRARY_FILE
SPEAKER_TRACE_FILE

Traits§

LivePcmWindowProcessor
LiveTranscriptionProgressObserver
SegmentTranslationProvider
A boundary that executes one planned model leg for one transcript segment.
TranscriptionProgressObserver

Functions§

build_transcription_request
compare_with_whisperx
correct_speaker
delete_speaker_profile
global_speaker_directory
import_whisperx_json
list_speaker_profiles
live_transcript_events_to_jsonl
local_speaker_directory
read_speaker_directory_state
rebuild_speaker_trace
reject_draft_speaker_profile_creation
resolve_automatic_workflow_selection
resolve_speaker_directory
run
run_live_asr_window
run_live_asr_window_with_observer
Runs one bounded native ASR Near-Live Window with operational progress.
run_many
run_many_reusing_native_provider
run_many_with_control
Runs a Multi-Input Transcription Run with progress and cooperative control.
run_many_with_observer
run_parity_fixture_suite
run_parity_preflight
run_with_control
Runs one finite Workflow Composition with progress and cooperative control.
run_with_observer
speaker_library_path
speaker_trace_path
translate_transcription
Executes a plan without taking ownership of or mutating the source result.
translate_transcription_with_control
Executes direct or Pivot Translation with ordered leg progress and cancellation.
update_speaker_profile
validate_speaker_library
validate_speaker_library_file
write_outputs