pub(crate) mod algorithm;
#[cfg(feature = "alignment")]
mod aligner;
#[cfg(feature = "alignment")]
mod builder;
pub(crate) mod core;
pub(crate) mod emissions_aligner;
pub(crate) mod emissions_api;
#[cfg(feature = "alignment")]
mod key;
mod normalizer;
mod normalizers;
#[cfg(feature = "alignment")]
mod set;
#[cfg(all(test, feature = "alignment"))]
pub(crate) mod test_fixtures;
#[cfg(feature = "alignment")]
pub use algorithm::compose::{DEFAULT_MAX_INTRA_SILENT_RUN, DEFAULT_MIN_SPEECH_COVERAGE};
#[cfg(feature = "alignment")]
pub use aligner::Aligner;
pub mod bundled {
pub mod wav2vec2_base_960h {
include!(concat!(env!("OUT_DIR"), "/wav2vec2_base_960h_tokens.rs"));
pub fn token_to_id(token: &str) -> Option<u32> {
VOCAB.iter().find(|(t, _)| *t == token).map(|(_, id)| *id)
}
}
#[cfg(test)]
mod tests {
use super::wav2vec2_base_960h::*;
#[test]
fn bundled_vocab_has_required_special_tokens() {
assert!(
VOCAB.len() >= 32,
"vocab suspiciously small: {}",
VOCAB.len()
);
assert_eq!(token_to_id("<pad>"), Some(PAD_TOKEN_ID));
assert_eq!(token_to_id("<unk>"), Some(UNK_TOKEN_ID));
assert_eq!(token_to_id("|"), Some(DELIMITER_TOKEN_ID));
}
#[test]
fn bundled_vocab_is_sorted_by_id() {
let ids: Vec<u32> = VOCAB.iter().map(|(_, id)| *id).collect();
let mut sorted = ids.clone();
sorted.sort();
assert_eq!(ids, sorted, "VOCAB must be sorted by id ascending");
}
#[test]
fn token_to_id_round_trips_every_vocab_entry() {
for (token, id) in VOCAB {
assert_eq!(token_to_id(token), Some(*id));
}
}
#[test]
fn token_to_id_returns_none_for_unknown() {
assert!(token_to_id("definitely-not-in-vocab").is_none());
}
}
}
#[cfg(feature = "alignment")]
pub use builder::AlignmentSetBuilder;
#[cfg(feature = "alignment")]
pub use key::{AlignerKey, AlignmentFallback};
pub use normalizer::{
DynTextNormalizer, NormalizationError, NormalizedText, TextNormalizer, WildcardBoundary,
};
pub use normalizers::{
ChineseNormalizer, EnglishNormalizer, JapaneseNormalizer, KoreanNormalizer, LatinNormalizer,
default_normalizer_for,
};
#[cfg(feature = "alignment")]
pub use set::{AlignmentLookup, AlignmentSet};