Skip to main content

native_whisperx/config/
alignment.rs

1//! Alignment configuration mapped onto the native transcript alignment provider.
2
3use std::path::PathBuf;
4
5use audio_analysis_transcription::AlignmentInterpolationMethod;
6use serde::{Deserialize, Serialize};
7
8use super::defaults::default_alignment_model_id;
9
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
11#[serde(rename_all = "camelCase")]
12pub struct AlignmentConfig {
13    #[serde(default)]
14    pub enabled: bool,
15    #[serde(default = "default_alignment_model_id")]
16    pub model_id: String,
17    #[serde(default)]
18    pub model_bundle: Option<PathBuf>,
19    #[serde(default)]
20    pub model_dir: Option<PathBuf>,
21    #[serde(default)]
22    pub model_cache_only: bool,
23    #[serde(default)]
24    pub interpolate_method: AlignmentInterpolationMethod,
25    #[serde(default)]
26    pub return_char_alignments: bool,
27}
28
29impl Default for AlignmentConfig {
30    fn default() -> Self {
31        Self {
32            enabled: true,
33            model_id: default_alignment_model_id(),
34            model_bundle: None,
35            model_dir: None,
36            model_cache_only: false,
37            interpolate_method: AlignmentInterpolationMethod::Nearest,
38            return_char_alignments: false,
39        }
40    }
41}