MCPcopy Create free account
hub / github.com/evilsocket/cake / load

Method load

cake-core/src/models/luxtts/tokenizer.rs:25–43  ·  view source on GitHub ↗

Load from tokens.txt (TSV: token\tID) and optional CMUdict-IPA file.

(tokens_path: &Path, dict_path: Option<&Path>)

Source from the content-addressed store, hash-verified

23impl Phonemizer {
24 /// Load from tokens.txt (TSV: token\tID) and optional CMUdict-IPA file.
25 pub fn load(tokens_path: &Path, dict_path: Option<&Path>) -> Result<Self> {
26 let token_map = Self::load_tokens(tokens_path)?;
27
28 let ipa_dict = if let Some(dp) = dict_path {
29 Self::load_cmudict_ipa(dp)?
30 } else {
31 HashMap::new()
32 };
33
34 let space_id = token_map.get(" ").or_else(|| token_map.get("sp")).copied();
35 let pad_id = token_map.get("<pad>").or_else(|| token_map.get("<blank>")).copied().unwrap_or(0);
36
37 Ok(Self {
38 ipa_dict,
39 token_map,
40 space_id,
41 pad_id,
42 })
43 }
44
45 /// Parse tokens.txt (each line: `token\tindex`).
46 /// Uses the LAST tab as separator so that tokens containing spaces work correctly.

Callers

nothing calls this directly

Calls 1

getMethod · 0.45

Tested by

no test coverage detected