use crate::pack::{FetchProgress, Pack, PackFile};
use oa::{Engine, Result};
use std::path::PathBuf;
pub(crate) const CREMA_D_PACK: Pack = Pack {
name: "crema_d",
version: "1.0.0",
license: "Open Database License + custom use terms",
files: &[PackFile {
name: "crema-d-mirror-main.tar.gz",
size: 2_934_014_374,
shake256: "48a4e8126c03cf2bc3f1853866ecc2ea23b6659cd14ce05fd9fc4c658347e718",
urls: &[
"https://gitlab.com/cs-cooper-lab/crema-d-mirror/-/archive/main/crema-d-mirror-main.tar.gz",
],
}],
};
pub const CLASSES: [&str; 6] = ["NEU", "HAP", "SAD", "ANG", "FEA", "DIS"];
pub const SAMPLE_RATE: usize = 16000;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum CremaDSplit {
#[default]
Train,
Validation,
Test,
}
#[derive(Clone, Debug)]
pub struct CremaDConfig {
pub split: CremaDSplit,
pub cache_dir: Option<PathBuf>,
}
impl Default for CremaDConfig {
fn default() -> Self {
Self {
split: CremaDSplit::Train,
cache_dir: None,
}
}
}
impl CremaDConfig {
#[inline]
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
impl super::CremaD {
#[inline]
pub fn load(config: &CremaDConfig) -> Result<Self> {
Self::load_on(&Engine::current()?, config)
}
#[inline]
pub fn load_on(engine: &Engine, config: &CremaDConfig) -> Result<Self> {
Self::load_with_progress_on(engine, config, &mut |_| true)
}
#[inline]
pub fn load_with_progress(
config: &CremaDConfig,
progress: &mut impl FnMut(FetchProgress) -> bool,
) -> Result<Self> {
Self::load_with_progress_on(&Engine::current()?, config, progress)
}
}