Exemple #1
0
        public void FullLexicon_VariousReplacementTests()
        {
            using var data = Assembly.GetExecutingAssembly().GetManifestResourceStream("TextToTalk.Lexicons.Tests.test.pls");
            if (data == null)
            {
                Assert.True(false);
            }

            using var sr = new StreamReader(data);
            var lexicon = sr.ReadToEnd();

            var lm  = new LexiconManager();
            var xml = XDocument.Parse(lexicon);

            lm.AddLexicon(xml, "test");

            var ssml = lm.MakeSsml("Alphinaud", "en-GB");

            Assert.True(ssml.Contains("Alphinaud") && ssml.Contains("<phoneme"));

            ssml = lm.MakeSsml("G'raha", "en-GB");
            Assert.True(ssml.Contains("Graha") && ssml.Contains("<phoneme"));

            ssml = lm.MakeSsml("Amalj'aa", "en-GB");
            Assert.True(ssml.Contains("Amaljaa") && ssml.Contains("<phoneme"));
        }
Exemple #2
0
        public void MakeSsml_Works_WithNoLexicons()
        {
            const string text = "This is some 'text'.";
            var          lm   = new LexiconManager();
            var          ssml = lm.MakeSsml(text, "en-US");

            Assert.True(ssml.Contains(text) && !ssml.Contains("<phoneme"));
        }
Exemple #3
0
        public void LongerGraphemes_AreReplacedFirst_Test4()
        {
            var lm      = new LexiconManager();
            var lexicon = new LexiconBuilder()
                          .WithLexeme(new Lexeme {
                Graphemes = new[] { "Eorzean", "Eorzea" }, Phoneme = "eɪ ɔrːzɪː ə"
            })
                          .Build();
            var xml = XDocument.Parse(lexicon);

            lm.AddLexicon(xml, "test");

            var ssml = lm.MakeSsml("Eorzean", "en-US");

            Assert.True(ssml.Contains("Eorzean"));
        }
Exemple #4
0
        public void LongerGraphemes_AreReplacedFirst_Test1()
        {
            var lm      = new LexiconManager();
            var lexicon = new LexiconBuilder()
                          .WithLexeme(new Lexeme {
                Graphemes = new[] { "Eorzea" }, Phoneme = "eɪ ɔrːzɪː ə"
            })
                          .WithLexeme(new Lexeme {
                Graphemes = new[] { "Eorzean" }, Phoneme = "eɪ ɔrːzɪːæn"
            })
                          .Build();
            var xml = XDocument.Parse(lexicon);

            lm.AddLexicon(xml, "test");

            var ssml = lm.MakeSsml("Eorzean", "en-US");

            Assert.True(ssml.Contains("Eorzean")); // If this is false, the "n" will be cut off and stuck at the end
        }
Exemple #5
0
        public void MakeSsml_Works_WithNoReplacements()
        {
            const string text    = "This is some 'text'.";
            var          lm      = new LexiconManager();
            var          lexicon = new LexiconBuilder()
                                   .WithLexeme(new Lexeme {
                Graphemes = new[] { "Bahamut" }, Phoneme = "bɑhɑmɪt", Alias = "Bahamoot"
            })
                                   .WithLexeme(new Lexeme {
                Graphemes = new[] { "Baldesion" }, Phoneme = "bɔldˈɛˈsiɑn"
            })
                                   .Build();
            var xml = XDocument.Parse(lexicon);

            lm.AddLexicon(xml, "test");
            var ssml = lm.MakeSsml(text, "en-US");

            Assert.True(ssml.Contains(text) && !ssml.Contains("<phoneme"));
        }
Exemple #6
0
        public void LongerGraphemes_AreReplacedFirst_Test7()
        {
            var lm      = new LexiconManager();
            var lexicon = new LexiconBuilder()
                          .WithLexeme(new Lexeme {
                Graphemes = new[] { "Amalj'aa" }, Phoneme = "a.mɔld͡ʒæ"
            })
                          .WithLexeme(new Lexeme {
                Graphemes = new[] { "Amalj'aas" }, Phoneme = "a.mɔld͡ʒæz"
            })
                          .Build();
            var xml = XDocument.Parse(lexicon);

            lm.AddLexicon(xml, "test");

            var ssml = lm.MakeSsml("Amalj'aas", "en-US");

            Assert.True(ssml.Contains("Amaljaas"));
        }
Exemple #7
0
        public void LongerGraphemes_AreReplacedFirst_Test6()
        {
            var lm      = new LexiconManager();
            var lexicon = new LexiconBuilder()
                          .WithLexeme(new Lexeme {
                Graphemes = new[] { "Y'shtola" }, Phoneme = "jiʃtoʊˈlɑ"
            })
                          .WithLexeme(new Lexeme {
                Graphemes = new[] { "'s" }, Phoneme = "z"
            })
                          .Build();
            var xml = XDocument.Parse(lexicon);

            lm.AddLexicon(xml, "test");

            var ssml = lm.MakeSsml("Y'shtola's", "en-US");

            Assert.True(ssml.Contains("Yshtola") && ssml.Contains("<phoneme ph=\"z\">s</phoneme>"));
        }
Exemple #8
0
        public void LongerGraphemes_AreReplacedFirst_Test5()
        {
            var lm      = new LexiconManager();
            var lexicon = new LexiconBuilder()
                          .WithLexeme(new Lexeme {
                Graphemes = new[] { "Vanu" }, Phoneme = "vɑːnu"
            })
                          .WithLexeme(new Lexeme {
                Graphemes = new[] { "Vanus" }, Phoneme = "vɑːnuz"
            })
                          .Build();
            var xml = XDocument.Parse(lexicon);

            lm.AddLexicon(xml, "test");

            var ssml = lm.MakeSsml("Vanu Vanus", "en-US");

            Assert.True(!ssml.Contains("Vanu Vanus") && ssml.Contains("Vanu") && ssml.Contains("Vanus"));
        }