use crate::constants::{
MAX_MODEL_SAMPLES, MEL_HOP_SAMPLES, SAMPLE_RATE, SAMPLES_PER_ENCODER_FRAME,
};
#[derive(Debug, Clone)]
pub struct TranscriptionConfig {
pub sample_rate: usize,
pub feature_size: usize,
pub n_fft: usize,
pub win_length: usize,
pub hop_length: usize,
pub preemphasis: f32,
pub max_audio_samples: usize,
pub samples_per_encoder_frame: usize,
}
impl Default for TranscriptionConfig {
fn default() -> Self {
Self {
sample_rate: SAMPLE_RATE,
feature_size: 128,
n_fft: 512,
win_length: 400,
hop_length: MEL_HOP_SAMPLES,
preemphasis: 0.97,
max_audio_samples: MAX_MODEL_SAMPLES,
samples_per_encoder_frame: SAMPLES_PER_ENCODER_FRAME,
}
}
}
impl TranscriptionConfig {
pub(crate) fn max_duration_seconds(&self) -> f64 {
self.max_audio_samples as f64 / self.sample_rate as f64
}
pub(crate) fn max_feature_frames(&self) -> usize {
self.max_audio_samples / self.hop_length + 1
}
}