style: cargo fmt --workspace (whitespace/wrapping only, no semantic change)

Whole-workspace rustfmt pass picked up while iterating on Mamba GPU
backward work. Verified formatting-only via diff sampling; no logic
changed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
osobh
2026-08-10 07:09:36 -07:00
co-authored by Claude Sonnet 5
parent ad6405663f
commit 4aaa36a57a
305 changed files with 25537 additions and 18337 deletions
+439 -58
View File
@@ -60,7 +60,10 @@ impl Phoneme {
/// Create a phoneme without stress
#[must_use]
pub fn unstressed(symbol: String) -> Self {
Self { symbol, stress: None }
Self {
symbol,
stress: None,
}
}
/// Convert phoneme to string representation
@@ -109,76 +112,452 @@ impl Phonemizer {
/// Populate the pronunciation dictionary with common English words
fn populate_dictionary(dict: &mut HashMap<String, Vec<Phoneme>>) {
// Pronouns
dict.insert("i".to_string(), vec![Phoneme::new("AY".to_string(), Some(1))]);
dict.insert("you".to_string(), vec![Phoneme::new("Y".to_string(), None), Phoneme::new("UW".to_string(), Some(1))]);
dict.insert("he".to_string(), vec![Phoneme::new("HH".to_string(), None), Phoneme::new("IY".to_string(), Some(1))]);
dict.insert("she".to_string(), vec![Phoneme::new("SH".to_string(), None), Phoneme::new("IY".to_string(), Some(1))]);
dict.insert("it".to_string(), vec![Phoneme::new("IH".to_string(), Some(1)), Phoneme::new("T".to_string(), None)]);
dict.insert("we".to_string(), vec![Phoneme::new("W".to_string(), None), Phoneme::new("IY".to_string(), Some(1))]);
dict.insert("they".to_string(), vec![Phoneme::new("DH".to_string(), None), Phoneme::new("EY".to_string(), Some(1))]);
dict.insert(
"i".to_string(),
vec![Phoneme::new("AY".to_string(), Some(1))],
);
dict.insert(
"you".to_string(),
vec![
Phoneme::new("Y".to_string(), None),
Phoneme::new("UW".to_string(), Some(1)),
],
);
dict.insert(
"he".to_string(),
vec![
Phoneme::new("HH".to_string(), None),
Phoneme::new("IY".to_string(), Some(1)),
],
);
dict.insert(
"she".to_string(),
vec![
Phoneme::new("SH".to_string(), None),
Phoneme::new("IY".to_string(), Some(1)),
],
);
dict.insert(
"it".to_string(),
vec![
Phoneme::new("IH".to_string(), Some(1)),
Phoneme::new("T".to_string(), None),
],
);
dict.insert(
"we".to_string(),
vec![
Phoneme::new("W".to_string(), None),
Phoneme::new("IY".to_string(), Some(1)),
],
);
dict.insert(
"they".to_string(),
vec![
Phoneme::new("DH".to_string(), None),
Phoneme::new("EY".to_string(), Some(1)),
],
);
// Common verbs
dict.insert("is".to_string(), vec![Phoneme::new("IH".to_string(), Some(1)), Phoneme::new("Z".to_string(), None)]);
dict.insert("are".to_string(), vec![Phoneme::new("AA".to_string(), Some(1)), Phoneme::new("R".to_string(), None)]);
dict.insert("was".to_string(), vec![Phoneme::new("W".to_string(), None), Phoneme::new("AA".to_string(), Some(1)), Phoneme::new("Z".to_string(), None)]);
dict.insert("have".to_string(), vec![Phoneme::new("HH".to_string(), None), Phoneme::new("AE".to_string(), Some(1)), Phoneme::new("V".to_string(), None)]);
dict.insert("had".to_string(), vec![Phoneme::new("HH".to_string(), None), Phoneme::new("AE".to_string(), Some(1)), Phoneme::new("D".to_string(), None)]);
dict.insert("do".to_string(), vec![Phoneme::new("D".to_string(), None), Phoneme::new("UW".to_string(), Some(1))]);
dict.insert("did".to_string(), vec![Phoneme::new("D".to_string(), None), Phoneme::new("IH".to_string(), Some(1)), Phoneme::new("D".to_string(), None)]);
dict.insert("said".to_string(), vec![Phoneme::new("S".to_string(), None), Phoneme::new("EH".to_string(), Some(1)), Phoneme::new("D".to_string(), None)]);
dict.insert("go".to_string(), vec![Phoneme::new("G".to_string(), None), Phoneme::new("OW".to_string(), Some(1))]);
dict.insert("went".to_string(), vec![Phoneme::new("W".to_string(), None), Phoneme::new("EH".to_string(), Some(1)), Phoneme::new("N".to_string(), None), Phoneme::new("T".to_string(), None)]);
dict.insert("make".to_string(), vec![Phoneme::new("M".to_string(), None), Phoneme::new("EY".to_string(), Some(1)), Phoneme::new("K".to_string(), None)]);
dict.insert("get".to_string(), vec![Phoneme::new("G".to_string(), None), Phoneme::new("EH".to_string(), Some(1)), Phoneme::new("T".to_string(), None)]);
dict.insert(
"is".to_string(),
vec![
Phoneme::new("IH".to_string(), Some(1)),
Phoneme::new("Z".to_string(), None),
],
);
dict.insert(
"are".to_string(),
vec![
Phoneme::new("AA".to_string(), Some(1)),
Phoneme::new("R".to_string(), None),
],
);
dict.insert(
"was".to_string(),
vec![
Phoneme::new("W".to_string(), None),
Phoneme::new("AA".to_string(), Some(1)),
Phoneme::new("Z".to_string(), None),
],
);
dict.insert(
"have".to_string(),
vec![
Phoneme::new("HH".to_string(), None),
Phoneme::new("AE".to_string(), Some(1)),
Phoneme::new("V".to_string(), None),
],
);
dict.insert(
"had".to_string(),
vec![
Phoneme::new("HH".to_string(), None),
Phoneme::new("AE".to_string(), Some(1)),
Phoneme::new("D".to_string(), None),
],
);
dict.insert(
"do".to_string(),
vec![
Phoneme::new("D".to_string(), None),
Phoneme::new("UW".to_string(), Some(1)),
],
);
dict.insert(
"did".to_string(),
vec![
Phoneme::new("D".to_string(), None),
Phoneme::new("IH".to_string(), Some(1)),
Phoneme::new("D".to_string(), None),
],
);
dict.insert(
"said".to_string(),
vec![
Phoneme::new("S".to_string(), None),
Phoneme::new("EH".to_string(), Some(1)),
Phoneme::new("D".to_string(), None),
],
);
dict.insert(
"go".to_string(),
vec![
Phoneme::new("G".to_string(), None),
Phoneme::new("OW".to_string(), Some(1)),
],
);
dict.insert(
"went".to_string(),
vec![
Phoneme::new("W".to_string(), None),
Phoneme::new("EH".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
Phoneme::new("T".to_string(), None),
],
);
dict.insert(
"make".to_string(),
vec![
Phoneme::new("M".to_string(), None),
Phoneme::new("EY".to_string(), Some(1)),
Phoneme::new("K".to_string(), None),
],
);
dict.insert(
"get".to_string(),
vec![
Phoneme::new("G".to_string(), None),
Phoneme::new("EH".to_string(), Some(1)),
Phoneme::new("T".to_string(), None),
],
);
// Common nouns
dict.insert("time".to_string(), vec![Phoneme::new("T".to_string(), None), Phoneme::new("AY".to_string(), Some(1)), Phoneme::new("M".to_string(), None)]);
dict.insert("day".to_string(), vec![Phoneme::new("D".to_string(), None), Phoneme::new("EY".to_string(), Some(1))]);
dict.insert("man".to_string(), vec![Phoneme::new("M".to_string(), None), Phoneme::new("AE".to_string(), Some(1)), Phoneme::new("N".to_string(), None)]);
dict.insert("woman".to_string(), vec![Phoneme::new("W".to_string(), None), Phoneme::new("UH".to_string(), Some(1)), Phoneme::new("M".to_string(), None), Phoneme::new("AH".to_string(), Some(0)), Phoneme::new("N".to_string(), None)]);
dict.insert("child".to_string(), vec![Phoneme::new("CH".to_string(), None), Phoneme::new("AY".to_string(), Some(1)), Phoneme::new("L".to_string(), None), Phoneme::new("D".to_string(), None)]);
dict.insert("world".to_string(), vec![Phoneme::new("W".to_string(), None), Phoneme::new("ER".to_string(), Some(1)), Phoneme::new("L".to_string(), None), Phoneme::new("D".to_string(), None)]);
dict.insert("house".to_string(), vec![Phoneme::new("HH".to_string(), None), Phoneme::new("AW".to_string(), Some(1)), Phoneme::new("S".to_string(), None)]);
dict.insert("book".to_string(), vec![Phoneme::new("B".to_string(), None), Phoneme::new("UH".to_string(), Some(1)), Phoneme::new("K".to_string(), None)]);
dict.insert(
"time".to_string(),
vec![
Phoneme::new("T".to_string(), None),
Phoneme::new("AY".to_string(), Some(1)),
Phoneme::new("M".to_string(), None),
],
);
dict.insert(
"day".to_string(),
vec![
Phoneme::new("D".to_string(), None),
Phoneme::new("EY".to_string(), Some(1)),
],
);
dict.insert(
"man".to_string(),
vec![
Phoneme::new("M".to_string(), None),
Phoneme::new("AE".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
],
);
dict.insert(
"woman".to_string(),
vec![
Phoneme::new("W".to_string(), None),
Phoneme::new("UH".to_string(), Some(1)),
Phoneme::new("M".to_string(), None),
Phoneme::new("AH".to_string(), Some(0)),
Phoneme::new("N".to_string(), None),
],
);
dict.insert(
"child".to_string(),
vec![
Phoneme::new("CH".to_string(), None),
Phoneme::new("AY".to_string(), Some(1)),
Phoneme::new("L".to_string(), None),
Phoneme::new("D".to_string(), None),
],
);
dict.insert(
"world".to_string(),
vec![
Phoneme::new("W".to_string(), None),
Phoneme::new("ER".to_string(), Some(1)),
Phoneme::new("L".to_string(), None),
Phoneme::new("D".to_string(), None),
],
);
dict.insert(
"house".to_string(),
vec![
Phoneme::new("HH".to_string(), None),
Phoneme::new("AW".to_string(), Some(1)),
Phoneme::new("S".to_string(), None),
],
);
dict.insert(
"book".to_string(),
vec![
Phoneme::new("B".to_string(), None),
Phoneme::new("UH".to_string(), Some(1)),
Phoneme::new("K".to_string(), None),
],
);
// Common adjectives
dict.insert("good".to_string(), vec![Phoneme::new("G".to_string(), None), Phoneme::new("UH".to_string(), Some(1)), Phoneme::new("D".to_string(), None)]);
dict.insert("great".to_string(), vec![Phoneme::new("G".to_string(), None), Phoneme::new("R".to_string(), None), Phoneme::new("EY".to_string(), Some(1)), Phoneme::new("T".to_string(), None)]);
dict.insert("new".to_string(), vec![Phoneme::new("N".to_string(), None), Phoneme::new("UW".to_string(), Some(1))]);
dict.insert("old".to_string(), vec![Phoneme::new("OW".to_string(), Some(1)), Phoneme::new("L".to_string(), None), Phoneme::new("D".to_string(), None)]);
dict.insert("big".to_string(), vec![Phoneme::new("B".to_string(), None), Phoneme::new("IH".to_string(), Some(1)), Phoneme::new("G".to_string(), None)]);
dict.insert("small".to_string(), vec![Phoneme::new("S".to_string(), None), Phoneme::new("M".to_string(), None), Phoneme::new("AO".to_string(), Some(1)), Phoneme::new("L".to_string(), None)]);
dict.insert(
"good".to_string(),
vec![
Phoneme::new("G".to_string(), None),
Phoneme::new("UH".to_string(), Some(1)),
Phoneme::new("D".to_string(), None),
],
);
dict.insert(
"great".to_string(),
vec![
Phoneme::new("G".to_string(), None),
Phoneme::new("R".to_string(), None),
Phoneme::new("EY".to_string(), Some(1)),
Phoneme::new("T".to_string(), None),
],
);
dict.insert(
"new".to_string(),
vec![
Phoneme::new("N".to_string(), None),
Phoneme::new("UW".to_string(), Some(1)),
],
);
dict.insert(
"old".to_string(),
vec![
Phoneme::new("OW".to_string(), Some(1)),
Phoneme::new("L".to_string(), None),
Phoneme::new("D".to_string(), None),
],
);
dict.insert(
"big".to_string(),
vec![
Phoneme::new("B".to_string(), None),
Phoneme::new("IH".to_string(), Some(1)),
Phoneme::new("G".to_string(), None),
],
);
dict.insert(
"small".to_string(),
vec![
Phoneme::new("S".to_string(), None),
Phoneme::new("M".to_string(), None),
Phoneme::new("AO".to_string(), Some(1)),
Phoneme::new("L".to_string(), None),
],
);
// Articles and common words
dict.insert("the".to_string(), vec![Phoneme::new("DH".to_string(), None), Phoneme::new("AH".to_string(), Some(0))]);
dict.insert("a".to_string(), vec![Phoneme::new("AH".to_string(), Some(0))]);
dict.insert("an".to_string(), vec![Phoneme::new("AE".to_string(), Some(1)), Phoneme::new("N".to_string(), None)]);
dict.insert("and".to_string(), vec![Phoneme::new("AE".to_string(), Some(1)), Phoneme::new("N".to_string(), None), Phoneme::new("D".to_string(), None)]);
dict.insert("or".to_string(), vec![Phoneme::new("AO".to_string(), Some(1)), Phoneme::new("R".to_string(), None)]);
dict.insert("but".to_string(), vec![Phoneme::new("B".to_string(), None), Phoneme::new("AH".to_string(), Some(1)), Phoneme::new("T".to_string(), None)]);
dict.insert("to".to_string(), vec![Phoneme::new("T".to_string(), None), Phoneme::new("UW".to_string(), Some(1))]);
dict.insert("in".to_string(), vec![Phoneme::new("IH".to_string(), Some(1)), Phoneme::new("N".to_string(), None)]);
dict.insert("on".to_string(), vec![Phoneme::new("AA".to_string(), Some(1)), Phoneme::new("N".to_string(), None)]);
dict.insert("at".to_string(), vec![Phoneme::new("AE".to_string(), Some(1)), Phoneme::new("T".to_string(), None)]);
dict.insert("for".to_string(), vec![Phoneme::new("F".to_string(), None), Phoneme::new("AO".to_string(), Some(1)), Phoneme::new("R".to_string(), None)]);
dict.insert("with".to_string(), vec![Phoneme::new("W".to_string(), None), Phoneme::new("IH".to_string(), Some(1)), Phoneme::new("DH".to_string(), None)]);
dict.insert(
"the".to_string(),
vec![
Phoneme::new("DH".to_string(), None),
Phoneme::new("AH".to_string(), Some(0)),
],
);
dict.insert(
"a".to_string(),
vec![Phoneme::new("AH".to_string(), Some(0))],
);
dict.insert(
"an".to_string(),
vec![
Phoneme::new("AE".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
],
);
dict.insert(
"and".to_string(),
vec![
Phoneme::new("AE".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
Phoneme::new("D".to_string(), None),
],
);
dict.insert(
"or".to_string(),
vec![
Phoneme::new("AO".to_string(), Some(1)),
Phoneme::new("R".to_string(), None),
],
);
dict.insert(
"but".to_string(),
vec![
Phoneme::new("B".to_string(), None),
Phoneme::new("AH".to_string(), Some(1)),
Phoneme::new("T".to_string(), None),
],
);
dict.insert(
"to".to_string(),
vec![
Phoneme::new("T".to_string(), None),
Phoneme::new("UW".to_string(), Some(1)),
],
);
dict.insert(
"in".to_string(),
vec![
Phoneme::new("IH".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
],
);
dict.insert(
"on".to_string(),
vec![
Phoneme::new("AA".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
],
);
dict.insert(
"at".to_string(),
vec![
Phoneme::new("AE".to_string(), Some(1)),
Phoneme::new("T".to_string(), None),
],
);
dict.insert(
"for".to_string(),
vec![
Phoneme::new("F".to_string(), None),
Phoneme::new("AO".to_string(), Some(1)),
Phoneme::new("R".to_string(), None),
],
);
dict.insert(
"with".to_string(),
vec![
Phoneme::new("W".to_string(), None),
Phoneme::new("IH".to_string(), Some(1)),
Phoneme::new("DH".to_string(), None),
],
);
// Numbers
dict.insert("one".to_string(), vec![Phoneme::new("W".to_string(), None), Phoneme::new("AH".to_string(), Some(1)), Phoneme::new("N".to_string(), None)]);
dict.insert("two".to_string(), vec![Phoneme::new("T".to_string(), None), Phoneme::new("UW".to_string(), Some(1))]);
dict.insert("three".to_string(), vec![Phoneme::new("TH".to_string(), None), Phoneme::new("R".to_string(), None), Phoneme::new("IY".to_string(), Some(1))]);
dict.insert("four".to_string(), vec![Phoneme::new("F".to_string(), None), Phoneme::new("AO".to_string(), Some(1)), Phoneme::new("R".to_string(), None)]);
dict.insert("five".to_string(), vec![Phoneme::new("F".to_string(), None), Phoneme::new("AY".to_string(), Some(1)), Phoneme::new("V".to_string(), None)]);
dict.insert(
"one".to_string(),
vec![
Phoneme::new("W".to_string(), None),
Phoneme::new("AH".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
],
);
dict.insert(
"two".to_string(),
vec![
Phoneme::new("T".to_string(), None),
Phoneme::new("UW".to_string(), Some(1)),
],
);
dict.insert(
"three".to_string(),
vec![
Phoneme::new("TH".to_string(), None),
Phoneme::new("R".to_string(), None),
Phoneme::new("IY".to_string(), Some(1)),
],
);
dict.insert(
"four".to_string(),
vec![
Phoneme::new("F".to_string(), None),
Phoneme::new("AO".to_string(), Some(1)),
Phoneme::new("R".to_string(), None),
],
);
dict.insert(
"five".to_string(),
vec![
Phoneme::new("F".to_string(), None),
Phoneme::new("AY".to_string(), Some(1)),
Phoneme::new("V".to_string(), None),
],
);
// Common contractions
dict.insert("can't".to_string(), vec![Phoneme::new("K".to_string(), None), Phoneme::new("AE".to_string(), Some(1)), Phoneme::new("N".to_string(), None), Phoneme::new("T".to_string(), None)]);
dict.insert("don't".to_string(), vec![Phoneme::new("D".to_string(), None), Phoneme::new("OW".to_string(), Some(1)), Phoneme::new("N".to_string(), None), Phoneme::new("T".to_string(), None)]);
dict.insert("won't".to_string(), vec![Phoneme::new("W".to_string(), None), Phoneme::new("OW".to_string(), Some(1)), Phoneme::new("N".to_string(), None), Phoneme::new("T".to_string(), None)]);
dict.insert(
"can't".to_string(),
vec![
Phoneme::new("K".to_string(), None),
Phoneme::new("AE".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
Phoneme::new("T".to_string(), None),
],
);
dict.insert(
"don't".to_string(),
vec![
Phoneme::new("D".to_string(), None),
Phoneme::new("OW".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
Phoneme::new("T".to_string(), None),
],
);
dict.insert(
"won't".to_string(),
vec![
Phoneme::new("W".to_string(), None),
Phoneme::new("OW".to_string(), Some(1)),
Phoneme::new("N".to_string(), None),
Phoneme::new("T".to_string(), None),
],
);
// Greetings
dict.insert("hello".to_string(), vec![Phoneme::new("HH".to_string(), None), Phoneme::new("AH".to_string(), Some(0)), Phoneme::new("L".to_string(), None), Phoneme::new("OW".to_string(), Some(1))]);
dict.insert("hi".to_string(), vec![Phoneme::new("HH".to_string(), None), Phoneme::new("AY".to_string(), Some(1))]);
dict.insert("goodbye".to_string(), vec![Phoneme::new("G".to_string(), None), Phoneme::new("UH".to_string(), Some(1)), Phoneme::new("D".to_string(), None), Phoneme::new("B".to_string(), None), Phoneme::new("AY".to_string(), Some(1))]);
dict.insert(
"hello".to_string(),
vec![
Phoneme::new("HH".to_string(), None),
Phoneme::new("AH".to_string(), Some(0)),
Phoneme::new("L".to_string(), None),
Phoneme::new("OW".to_string(), Some(1)),
],
);
dict.insert(
"hi".to_string(),
vec![
Phoneme::new("HH".to_string(), None),
Phoneme::new("AY".to_string(), Some(1)),
],
);
dict.insert(
"goodbye".to_string(),
vec![
Phoneme::new("G".to_string(), None),
Phoneme::new("UH".to_string(), Some(1)),
Phoneme::new("D".to_string(), None),
Phoneme::new("B".to_string(), None),
Phoneme::new("AY".to_string(), Some(1)),
],
);
}
/// Convert text to phonemes
@@ -258,7 +637,9 @@ impl Phonemizer {
}
if phonemes.is_empty() {
return Err(TtsError::Phonemization(format!("Could not phonemize word: {word}")));
return Err(TtsError::Phonemization(format!(
"Could not phonemize word: {word}"
)));
}
Ok(phonemes)