diff --git a/.idea/misc.xml b/.idea/misc.xml index edcfdf64e7..5a8ab0f6bf 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,22 +1,15 @@ + + + - - - - - - - - - - - + - \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 3c7eeb73a0..3f1b28b26a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,11 +6,28 @@ dependencies = [ "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "aho-corasick" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ansi_term" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "arpabet" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "bitflags" version = "0.4.0" @@ -256,6 +273,11 @@ name = "lazy_static" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "lazy_static" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" version = "0.2.42" @@ -298,6 +320,14 @@ dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "memchr" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "mime" version = "0.2.6" @@ -602,11 +632,31 @@ dependencies = [ "utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex-syntax" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "regex-syntax" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "remove_dir_all" version = "0.5.1" @@ -744,6 +794,15 @@ dependencies = [ "thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "thread_local" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "time" version = "0.1.40" @@ -776,6 +835,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "trumpet" version = "0.12.0" dependencies = [ + "arpabet 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.2.25 (registry+https://github.com/rust-lang/crates.io-index)", "clap 1.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "hound 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -809,6 +869,11 @@ dependencies = [ "unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "ucd-util" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicase" version = "1.4.2" @@ -838,6 +903,14 @@ name = "unicode-normalization" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "unreachable" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "unsafe-any" version = "0.4.2" @@ -893,6 +966,11 @@ name = "utf8-ranges" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "utf8-ranges" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "uuid" version = "0.2.3" @@ -911,6 +989,11 @@ name = "version_check" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "walkdir" version = "1.0.7" @@ -952,7 +1035,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum aho-corasick 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ca972c2ea5f742bfce5687b9aef75506a764f61d37f8f649047846a9686ddb66" +"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4" "checksum ansi_term 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)" = "30275ad0ad84ec1c06dde3b3f7d23c6006b7d76d61a85e7060b426b747eff70d" +"checksum arpabet 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b081353c1449ead03c04cf84b577c928a8671a99bd7ed9d3ad2e4be7bc596819" "checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d0c54bb8f454c567f21197eefcdbf5679d0bd99f2ddbe52e84c77061952e6789" @@ -982,12 +1067,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" "checksum lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "cf186d1a8aa5f5bee5fd662bc9c1b949e0259e1bcc379d1f006847b0080c7417" "checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" +"checksum lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e6412c5e2ad9584b0b8e979393122026cdd6d2a80b933f890dcd694ddbe73739" "checksum libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" = "b685088df2b950fccadf07a7187c8ef846a959c142338a48f9dc0b94517eb5f1" "checksum libressl-pnacl-sys 2.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "cbc058951ab6a3ef35ca16462d7642c4867e6403520811f28537a4e2f2db3e71" "checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6fddaa003a65722a7fb9e26b0ce95921fe4ba590542ced664d8ce2fa26f9f3ac" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" +"checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mime_guess 1.8.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b7e2b09d08313f84e0fb82d13a4d859109a17543fe9af3b6d941dc1431f7de79" "checksum modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f5c9112cb662acd3b204077e0de5bc66305fa8df65c8019d5adb10e9ab6e58" @@ -1021,7 +1108,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5" "checksum redox_syscall 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "c214e91d3ecf43e9a4e41e578973adeb14b474f2bee858742d127af75a0112b1" "checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f" +"checksum regex 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "75ecf88252dce580404a22444fc7d626c01815debba56a7f4f536772a5ff19d3" "checksum regex-syntax 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "f9ec002c35e86791825ed294b50008eea9ddfc8def4420124fbc6b08db834957" +"checksum regex-syntax 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8f1ac0f60d675cc6cf13a20ec076568254472551051ad5dd050364d70671bf6b" "checksum remove_dir_all 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3488ba1b9a2084d38645c4c08276a1752dcbf2c7130d74f1569681ad5d2799c5" "checksum resolve 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a40df559bf6f525f5543572ca8c2a49c96c3ca0debfcb00c499dce9bf4ff548" "checksum route-recognizer 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3255338088df8146ba63d60a9b8e3556f1146ce2973bc05a75181a42ce2256" @@ -1039,25 +1128,30 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8" "checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03" "checksum thread_local 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8576dbbfcaef9641452d5cf0df9b0e7eeab7694956dd33bb61515fb8f18cfdd5" +"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963" "checksum time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)" = "d825be0eb33fda1a7e68012d51e9c7f451dc1a69391e7fdc197060bb8c56667b" "checksum toml 0.1.30 (registry+https://github.com/rust-lang/crates.io-index)" = "0590d72182e50e879c4da3b11c6488dae18fccb1ae0c7a3eda18e16795844796" "checksum traitobject 0.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "07eaeb7689bb7fca7ce15628319635758eda769fed481ecfe6686ddef2600616" "checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typemap 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "653be63c80a3296da5551e1bfd2cca35227e13cdd08c6668903ae2f4f77aa1f6" +"checksum ucd-util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "fd2be2d6639d0f8fe6cdda291ad456e23629558d466e2789d2c3e9892bda285d" "checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicode-bidi 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "149319afc0ec718611d4a9208c0308e3b1b62dcfbd982e5e723f6ec35b909b92" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0180bc61fc5a987082bfa111f4cc95c4caff7f9799f3e46df09163a937aa25" +"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum unsafe-any 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f30360d7979f5e9c6e6cea48af192ea8fab4afb3cf72597154b8f08935bc9c7f" "checksum url 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4a3440c1ed62af4a2aee71c6fb78ef32ddcb75cfa24bf42f45e07c02b6d6a2f6" "checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7" "checksum urlencoded 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5ddcf2d3a0beedb5cdf50cabc521ab76a994907877a1d91d996c251d42c70e2e" "checksum user32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ef4711d107b21b410a3a974b1204d9accc8b10dad75d8324b5d755de1617d47" "checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f" +"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum uuid 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "885acc3b17fdef6230d1f7765dff1106dfd5e75a93c2f26459fbf600ed6dcc14" "checksum vec_map 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1805118a0d7c72d427e9d9c8134b549ec9e88942c707b100deef357ec0948f02" "checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "773ef9dcc5f24b7d850d0ff101e542ff24c3b090a9768e03ff889fdef41f00fd" diff --git a/Cargo.toml b/Cargo.toml index 4527cd49a2..17c4dae073 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ [dependencies] #cpal = "*" # Hardware audio output (for testing); works well with Hound. + arpabet = "0.2" chrono = { version = "0.2.*", features = ["rustc-serialize"] } clap = "1.5.*" # CLI parsing. hound = "2.0.*" # WAV codec. diff --git a/dictionary/square-dict b/dictionary/square-dict index e64cb117b9..ee5f218fe7 100644 --- a/dictionary/square-dict +++ b/dictionary/square-dict @@ -17,9 +17,9 @@ PAGERDUTY P EY1 JH ER0 D UW1 T IY0 SQROOT S K W EH1 R R UW1 T SQWEB S K W EH1 R W EH1 B TRACON T R AE1 K AA1 N -; -; TODO -- -; -; BITBUCKET -; TINMINATOR -; TYPESCRIPT +;;; +;;; TODO -- +;;; +;;; BITBUCKET +;;; TINMINATOR +;;; TYPESCRIPT diff --git a/src/lang/arpabet.rs b/src/lang/arpabet.rs deleted file mode 100644 index 50a910cd48..0000000000 --- a/src/lang/arpabet.rs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) 2016 Brandon Thomas - -use super::dictionary::Dictionary; -use error::SynthError; -use regex::Regex; -use std::collections::HashMap; -use std::collections::HashSet; -use std::fs::File; -use std::io::BufRead; -use std::io::BufReader; - -pub type Word = String; -pub type Phoneme = String; -pub type Polyphone = Vec; - -pub struct Arpabet { - /// A map of lowercase words to polyphone breakdown (phones are uppercase). - /// eg. 'jungle' -> [JH, AH1, NG, G, AH0, L] - dictionary: HashMap -} - -impl Arpabet { - /// Read CMU's Arpabet Dictionary. - /// See http://www.speech.cs.cmu.edu/cgi-bin/cmudict - pub fn load_from_file(filename: &str) -> Result { - let f = try!(File::open(filename)); - let mut reader = BufReader::new(f); - - let mut map = HashMap::new(); - let mut buffer = String::new(); - - // Format resembles the following, - // ABBREVIATE AH0 B R IY1 V IY0 EY2 T - let re = Regex::new(r"^([\w-']+)\s+(.*)\n$").unwrap(); - - while try!(reader.read_line(&mut buffer)) > 0 { - match re.captures(&buffer) { - None => {}, - Some(caps) => { - let word_match = caps.at(1); - let phonemes_match = caps.at(2); - - if word_match.is_some() && phonemes_match.is_some() { - let word = word_match.unwrap().to_lowercase(); - let split = phonemes_match.unwrap().split(" "); - let v1 = split.collect::>(); - let v2 = v1.iter().map(|s| s.to_string()).collect::>(); - map.insert(word, v2); - } - }, - } - buffer.clear(); - } - - if map.is_empty() { - Err(SynthError::EmptyFile) - } else { - Ok(Arpabet { dictionary: map }) - } - } - - /// Get a polyphone from the dictionary. - pub fn get_polyphone(&self, word: &str) -> Option { - self.dictionary.get(word).and_then(|p| { - Some(p.iter().map(|s| s.to_string()).collect::>()) - }) - } - - /// Combine two dictionaries into a new one. - pub fn combine(&self, other: &Arpabet) -> Arpabet { - let mut combined = self.dictionary.clone(); - for (k, v) in other.dictionary.iter() { - combined.insert(k.clone(), v.clone()); - } - - Arpabet { - dictionary: combined - } - } - - /// Extract and return the internal word dictionary (a list of all - /// the words contained in the arpabet). - pub fn to_dictionary(&self) -> Dictionary { - let mut words = HashSet::new(); - for word in self.dictionary.keys() { - words.insert(word.to_string()); - } - Dictionary::new(words) - } -} - diff --git a/src/lang/dictionary.rs b/src/lang/dictionary.rs index 2407af19cb..a71dc12947 100644 --- a/src/lang/dictionary.rs +++ b/src/lang/dictionary.rs @@ -1,8 +1,9 @@ // Copyright (c) 2016 Brandon Thomas +use arpabet::Arpabet; use speaker::Speaker; -use std::collections::HashSet; use std::collections::HashMap; +use std::collections::HashSet; pub type Word = String; @@ -27,6 +28,17 @@ impl Dictionary { Dictionary { words: HashSet::new() } } + + /// Extract and return the internal word dictionary (a list of all + /// the words contained in the arpabet). + pub fn from_arpabet(arpabet: &Arpabet) -> Dictionary { + let mut words = HashSet::new(); + for word in arpabet.keys() { + words.insert(word.to_string()); + } + Dictionary::new(words) + } + /// Returns true if the dictionary contains the word. pub fn contains(&self, word: &str) -> bool { self.words.contains(word) diff --git a/src/lang/mod.rs b/src/lang/mod.rs index 2e47c1abf9..8844ff805b 100644 --- a/src/lang/mod.rs +++ b/src/lang/mod.rs @@ -1,7 +1,6 @@ // Copyright (c) 2016 Brandon Thomas pub mod abbr; -pub mod arpabet; pub mod dates; pub mod dictionary; pub mod numbers; diff --git a/src/main.rs b/src/main.rs index d91178277b..a53069058f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; +extern crate arpabet; extern crate chrono; extern crate clap; extern crate crypto; @@ -27,6 +28,7 @@ pub mod old_dictionary; pub mod speaker; pub mod synthesis; +use arpabet::Arpabet; use clap::{App, Arg, ArgMatches}; use config::Config; use handlers::audio_synth_handler::AudioSynthHandler; @@ -35,7 +37,7 @@ use handlers::html_handler::HtmlHandler; use handlers::vocab_list_handler::VocabListHandler; use iron::prelude::*; use lang::abbr::AbbreviationsMap; -use lang::arpabet::Arpabet; +use lang::dictionary::Dictionary; use lang::dictionary::UniversalDictionary; use lang::parser::Parser; use lang::tokenizer::Tokenizer; @@ -145,23 +147,25 @@ fn get_hostname() { fn create_parser_and_synthesizer(config: &Config) -> (Parser, Synthesizer) { info!("Reading Arpabet Dictionary..."); - let arpabet_dictionary = Arpabet::load_from_file( - &config.phoneme_dictionary_file.clone().unwrap()).unwrap(); + let cmudict = Arpabet::load_cmudict(); info!("Reading Extra Dictionary..."); let extra_dictionary = Arpabet::load_from_file( - &config.extra_dictionary_file.clone().unwrap()).unwrap(); + &config.extra_dictionary_file.clone().unwrap()) + .expect("Error loading extra dictionary"); info!("Reading Square Dictionary..."); let square_dictionary = Arpabet::load_from_file( - &config.square_dictionary_file.clone().unwrap()).unwrap(); + &config.square_dictionary_file.clone().unwrap()) + .expect("Error reading square dictionary"); - let arpabet = arpabet_dictionary + let arpabet = cmudict .combine(&extra_dictionary) .combine(&square_dictionary); let mut dictionary = UniversalDictionary::new(); - dictionary.set_arpabet_dictionary(arpabet.to_dictionary()); + let arpa_dict = Dictionary::from_arpabet(&arpabet); + dictionary.set_arpabet_dictionary(arpa_dict); let dictionary = Arc::new(dictionary); diff --git a/src/synthesis/synthesizer.rs b/src/synthesis/synthesizer.rs index ef7defd7fc..f4cb9f746d 100644 --- a/src/synthesis/synthesizer.rs +++ b/src/synthesis/synthesizer.rs @@ -1,8 +1,8 @@ // Copyright (c) 2016 Brandon Thomas +use arpabet::Arpabet; use hound::WavSpec; use hound::WavWriter; -use lang::arpabet::Arpabet; use speaker::Speaker; use std::io::BufWriter; use std::io::Cursor; diff --git a/src/synthesis/word_synthesizer.rs b/src/synthesis/word_synthesizer.rs index f73a224498..882550a691 100644 --- a/src/synthesis/word_synthesizer.rs +++ b/src/synthesis/word_synthesizer.rs @@ -1,6 +1,6 @@ // Copyright (c) 2016 Brandon Thomas -use lang::arpabet::Arpabet; +use arpabet::Arpabet; use lang::syllables::Polysyllabic; use lang::syllables::Polysyllable; use lang::syllables::arpabet_to_syllables;