use super::measures::SampleRate;
#[derive(Debug, Clone, Copy)]
pub struct ClusterConfig {
pub threshold: f32,
pub max_speakers: usize,
pub min_cluster_size: usize,
pub min_cluster_secs: f64,
}
impl Default for ClusterConfig {
fn default() -> Self {
Self {
threshold: 0.45,
max_speakers: 64,
min_cluster_size: 2,
min_cluster_secs: 0.0,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct WindowConfig {
pub window_secs: f32,
pub hop_secs: f32,
pub sample_rate: SampleRate,
}
impl Default for WindowConfig {
fn default() -> Self {
Self {
window_secs: 1.5,
hop_secs: 0.75,
sample_rate: SampleRate::default(),
}
}
}
impl WindowConfig {
pub fn window_samples(&self) -> usize {
(self.window_secs * self.sample_rate.get() as f32) as usize
}
pub fn hop_samples(&self) -> usize {
(self.hop_secs * self.sample_rate.get() as f32) as usize
}
}
#[derive(Debug, Clone, Copy)]
pub struct SpeechFilterConfig {
pub min_speech_secs: f32,
pub max_gap_secs: f32,
}
impl Default for SpeechFilterConfig {
fn default() -> Self {
Self {
min_speech_secs: 0.25,
max_gap_secs: 0.5,
}
}
}
#[derive(Debug, Clone, Copy)]
pub struct DiarizationConfig {
pub cluster: ClusterConfig,
pub window: WindowConfig,
pub speech_filter: SpeechFilterConfig,
pub max_duration_secs: f32,
}
impl Default for DiarizationConfig {
fn default() -> Self {
Self {
cluster: ClusterConfig::default(),
window: WindowConfig::default(),
speech_filter: SpeechFilterConfig::default(),
max_duration_secs: 3600.0,
}
}
}
impl DiarizationConfig {
pub fn window_samples(&self) -> usize {
self.window.window_samples()
}
pub fn hop_samples(&self) -> usize {
self.window.hop_samples()
}
}