示例#1
0
        public void ReplaceGrapheme_DoesNotDeepReplace()
        {
            var s = LexiconManager.ReplaceGrapheme("Vanu Vanus", "Vanus", "<phoneme>Vanus</phoneme>");
            var t = LexiconManager.ReplaceGrapheme(s, "Vanu", "<phoneme>Vanu</phoneme>");

            Assert.Equal("<phoneme>Vanu</phoneme> <phoneme>Vanus</phoneme>", t);
        }
示例#2
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"));
        }
示例#3
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"));
        }
示例#4
0
        public SystemSoundQueue(LexiconManager lexiconManager)
        {
            this.speechCompleted   = new AutoResetEvent(false);
            this.lexiconManager    = lexiconManager;
            this.speechSynthesizer = new SpeechSynthesizer();

            this.speechSynthesizer.SpeakCompleted += (_, _) =>
            {
                // Allows PlaySoundLoop to continue.
                this.speechCompleted.Set();
            };
        }
示例#5
0
        public void LexiconBuilder_DoesBuildCorrectly()
        {
            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");
        }
示例#6
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"));
        }
示例#7
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
        }
示例#8
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"));
        }
示例#9
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"));
        }
示例#10
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>"));
        }
示例#11
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"));
        }