Beispiel #1
0
 public void FeedBack(string message, int speed = 0)
 {
     Speaker spkr = new Speaker(Language.Norwegian);
             spkr.Speak(message, speed);
 }
Beispiel #2
0
        private void ReadConfig(Enum choice)
        {
            // read the XML file from                       v here
                                _path = Directory.GetCurrentDirectory() + @"\Dependency\Config\Config.xml";
                                XmlDocument xmldoc = new XmlDocument();
                                xmldoc.Load(new StreamReader(_path));
                                if (xmldoc.DocumentElement == null)
                                    {
                                        return;
                                    }
                                var nodeList = xmldoc.DocumentElement.SelectNodes("Server"); // <- This gets the stuff related to servers, all of it

                                //Console.WriteLine(nodeList[0].NextSibling.SelectSingleNode("table").InnerText);

                                try
                                    {
                                        if (choice.Equals(ConfigType.Students)) // if you want to find a students RF data, do this
                                            {

                                                ConfStrings[0] = nodeList[0].SelectSingleNode("address").InnerText;
                                                ConfStrings[1] = nodeList[0].SelectSingleNode("sqldirectory").InnerText;
                                                ConfStrings[2] = nodeList[0].SelectSingleNode("table").InnerText;
                                                ConfStrings[3] = nodeList[0].SelectSingleNode("dbuser").InnerText;
                                                ConfStrings[4] = nodeList[0].SelectSingleNode("dbpass").InnerText;

                                            }
                                        else
                                            {
                                                // this is teacher data
                                                ConfStrings[0] = nodeList[0].NextSibling.SelectSingleNode("address").InnerText;
                                                ConfStrings[1] = nodeList[0].NextSibling.SelectSingleNode("sqldirectory").InnerText;
                                                ConfStrings[2] = nodeList[0].NextSibling.SelectSingleNode("table").InnerText;
                                                ConfStrings[3] = nodeList[0].NextSibling.SelectSingleNode("dbuser").InnerText;
                                                ConfStrings[4] = nodeList[0].NextSibling.SelectSingleNode("dbpass").InnerText;
                                            }
                                        if (DiagXML)
                                            {
                                                Speaker sp = new Speaker(Language.Norwegian);
                                                var str = "XML status: filtilgang og lesning OK";
                                                sp.Speak(str, 0);

                                            }
                                    }
                                catch (Exception e)
                                    {
                                        Console.WriteLine(e); // you done f****d up.
                                    }
        }
Beispiel #3
0
        private void ReadWords(ref XmlNodeList node, LangType lang, int XmlLangIndex)
        {
            try
                            {
                            LangStrings[(int)lang, (int)LangWord.CustLang] = node[XmlLangIndex].SelectSingleNode("Lang").InnerText;
                            LangStrings[(int)lang, (int)LangWord.DayStart] = node[XmlLangIndex].SelectSingleNode("DayStart").InnerText;
                            LangStrings[(int)lang, (int)LangWord.LunchStart] = node[XmlLangIndex].SelectSingleNode("LunchStart").InnerText;
                            LangStrings[(int)lang, (int)LangWord.LunchEnd] = node[XmlLangIndex].SelectSingleNode("LunchEnd").InnerText;
                            LangStrings[(int)lang, (int)LangWord.DayEnd] = node[XmlLangIndex].SelectSingleNode("DayEnd").InnerText;
                            LangStrings[(int)lang, (int)LangWord.WeekEnd] = node[XmlLangIndex].SelectSingleNode("WeekEnd").InnerText;
                            LangStrings[(int)lang, (int)LangWord.ErrorFlex] = node[XmlLangIndex].SelectSingleNode("ErrorFlex").InnerText;
                            LangStrings[(int)lang, (int)LangWord.LunchComment] = node[XmlLangIndex].SelectSingleNode("LunchComment").InnerText;
                            LangStrings[(int)lang, (int)LangWord.SignOutComment] = node[XmlLangIndex].SelectSingleNode("SignOutComment").InnerText;
                            LangStrings[(int)lang, (int)LangWord.BufferTime] = node[XmlLangIndex].SelectSingleNode("BufferTime").InnerText;
                            LangStrings[(int)lang, (int)LangWord.DoubleLogin] = node[XmlLangIndex].SelectSingleNode("DoubleLogin").InnerText;
                            LangStrings[(int)lang, (int)LangWord.DoubleLunch] = node[XmlLangIndex].SelectSingleNode("DoubleLunch").InnerText;
                            LangStrings[(int)lang, (int)LangWord.TooSoon] = node[XmlLangIndex].SelectSingleNode("TooSoon").InnerText;
                            LangStrings[(int)lang, (int)LangWord.NoEntryThisHour] = node[XmlLangIndex].SelectSingleNode("NoEntryThisHour").InnerText;
                            LangStrings[(int)lang, (int)LangWord.UnExpectedError9000] = node[XmlLangIndex].SelectSingleNode("UnExpectedError9000").InnerText;

                            }
                        catch (Exception)
                            {
                                Speaker sp = new Speaker();
                                sp.Speak("Error Reading XML language file");

                            }
        }
Beispiel #4
0
        // TODO: Surround with try-catch
        public void Process(Language lang, string say, int speed = 0, string custLang = null)
        {
            Language curLanguage = lang;
                if (Program.CustomProfile)
                    {
                        if (custLang != null)
                            {
                                if (custLang.Equals("NOR"))
                                    {
                                    curLanguage = Language.Norwegian;
                                    }
                                else if (custLang.Equals("SWE"))
                                    {
                                    curLanguage = Language.Swedish;
                                    }
                                else if (custLang.Equals("FIN"))
                                    {
                                    curLanguage = Language.Finish;
                                    }
                                else if (custLang.Equals("RUS"))
                                    {
                                    curLanguage = Language.Russian;
                                    }
                                else
                                    {
                                    curLanguage = Language.English; // english default
                                    }
                            }
                    }
                Speaker sp = new Speaker(curLanguage);

            if (say.Contains("@phonetic"))
                sp.UseSSML = true;

            // Speech Macro Processor
            int spPos = 0;
            for (int i = 0; i < say.Length; i++)
            {
                if (say[i] == '@')
                {
                // @wav(Pacman.wav)
                if (say.Substring(i).StartsWith("@wav(Pacman.wav)"))
                    {
                    sp.Speak(say.Substring(spPos, i - spPos), speed);
                    spPos = i + "@wav(Pacman.wav)".Length;

                    AudioPlayer ap = new AudioPlayer("wav(Pacman.wav).wav");
                    ap.Play();
                    }

                    // @phonetic(...)
                    if (say.Substring(i).StartsWith("@phonetic("))
                        {
                        sp.Speak(say.Substring(spPos, i - spPos), speed);
                        spPos = i + "@phonetic(".Length;

                        // TODO: try-catch
                        // Find closing ')'
                        string ph = say.Substring(spPos, say.Substring(spPos).IndexOf(')'));
                        spPos += ph.Length + 1;

                        // Speak with phonetic
                        //Speaker spph = new Speaker(lang);
                        //spph.UseSSML = true;
                        //spph.Speak(spph.Phonetic(ph));
                        sp.Speak(sp.Phonetic(ph), speed);
                        }

                        // @wav(...)

                    if (say.Substring(i).StartsWith("@wav("))
                        {
                        sp.Speak(say.Substring(spPos, i - spPos), speed);
                        spPos = i + "@wav(".Length;

                        // TODO: try-catch
                        // Find closing ')'
                        string ph = say.Substring(spPos, say.Substring(spPos).IndexOf(')'));
                        spPos += ph.Length + 1;
                        AudioPlayer ap = new AudioPlayer(ph);
                        ap.Play();
                        }

                }

            }
            sp.Speak(say.Substring(spPos), speed);
        }