#![cfg(feature = "alignment")]
use std::path::Path;
use asry::{Aligner, EnglishNormalizer, Lang};
const W2V_MODEL: Option<&str> = option_env!("ASRY_W2V_MODEL");
const W2V_TOKENIZER: Option<&str> = option_env!("ASRY_W2V_TOKENIZER");
const FIXTURE_OPT_IN: &str = "ASRY_FETCH_W2V=en cargo test --features alignment";
#[test]
#[cfg_attr(
not(asry_w2v_en),
ignore = "needs the English wav2vec2 fixture: ASRY_FETCH_W2V=en cargo test --features alignment"
)]
fn from_paths_loads_bundled_wav2vec2_fixtures() {
let model_path = W2V_MODEL.unwrap_or_else(|| {
panic!(
"alignment fixture missing: build.rs never emitted `ASRY_W2V_MODEL`. Fetch it and \
re-run:\n\n {FIXTURE_OPT_IN}\n"
)
});
let tokenizer_path = W2V_TOKENIZER.unwrap_or_else(|| {
panic!(
"alignment fixture missing: build.rs never emitted `ASRY_W2V_TOKENIZER`. Fetch it and \
re-run:\n\n {FIXTURE_OPT_IN}\n"
)
});
let aligner = Aligner::from_paths(
Lang::En,
Path::new(model_path),
Path::new(tokenizer_path),
Box::new(EnglishNormalizer::new()),
)
.expect("Aligner::from_paths must succeed against the bundled fixture");
assert_eq!(*aligner.language(), Lang::En);
assert_eq!(aligner.sample_rate(), 16_000);
assert_eq!(aligner.hop_samples(), 320);
assert_eq!(aligner.blank_token_id(), 0);
}