Пример #1
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);
        }
Пример #2
0
        private void DataRecievedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            //LogThings.Report(@"Reader.cs", @"DataRecievedHandler, Begin");
                        // returns the ID read from tag, provides easteregg.
                    //LogThings.Report(@"Reader.cs", @"DataRecievedHandler, setting local vars, serialport and databasemanager");
                        var serp = (SerialPort) sender;
                        var dbm = new DatabaseManager();
                        var DiagnosticID = "4510720867";
                        var BlueOysterID = "4475412741"; // 4475412741 tommy oyster// 4519992145 - old

                        rfid = serp.ReadExisting().Trim();
                        //LogThings.Report(@"Reader.cs", @"DataRecievedHandler, Detected RFID: " + rfid);
                        //Console.WriteLine(rfid);
                        if (rfid == DiagnosticID)
                            {
                            //LogThings.Report(@"Reader.cs", @"DataRecievedHandler, Diagnostic RFID detected");
                                // Play blue oyster soundtrack.
                                //Console.WriteLine("Dun duu du du duuu duu duuu");
                                Diagnostic = true;
                                if (Diagnostic)
                                    {
                                    //LogThings.Report(@"Reader.cs", @"DataRecievedHandler, Calling PrintDiagnosticData");
                                        PrintDiagnosticData(DiagnosticID);
                                    }
                            }
                            else if (rfid == BlueOysterID)
                            {
                            //LogThings.Report(@"Reader.cs", @"DataRecievedHandler, BlueOyster...");
                                AudioPlayer ap = new AudioPlayer("Blue Oyster Bar.wav");
                                ap.Play();
                            }
                        else
                            {
                            //LogThings.Report(@"Reader.cs", @"DataRecievedHandler, Populating field string array with databasemanager returned result");
                                _orgData = dbm.GenerateData(rfid, this); //The data giveth the data taketh
                            //LogThings.Report(@"Reader.cs", @"DataRecievedHandler, END");
                            }
        }