Example #1
0
        private void Initialize(string connectionString)
        {
            IDataAccessManager     database = null;
            SensoryMotorSystem     machine  = null;
            VisualProcessingSystem vision   = null;

            Gala.Data.Runtime.ContextCache newContextCache = null;
            IRobot          robot    = null;
            IChatbotManager chatbots = null;

            Galatea.Speech.ISpeechModule      speech = null;
            Galatea.Speech.ITextToSpeech      tts    = null;
            Galatea.Speech.ISpeechRecognition sr     = null;

            try
            {
                // Load Memory Library
                database = new Gala.Data.Databases.SerializedDataAccessManager(connectionString);
                database.Initialize(this);

                // Load Robotics Interfaces
                InitializationStatusUpdated?.Invoke(this, new EngineInitializationEventArgs(2, EngineInitializationResources.Engine_Initializing_Machine));
                machine = new Galahad.Robotics.MachineSystem();
                machine.Initialize(this);

                InitializationStatusUpdated?.Invoke(this, new EngineInitializationEventArgs(20, EngineInitializationResources.Engine_Initializing_Visuals));
                vision = new VisualProcessor(_settings.ImagingSettings);
                vision.Initialize(this);

                // Become Self-Aware
                InitializationStatusUpdated?.Invoke(this, new EngineInitializationEventArgs(33, EngineInitializationResources.Engine_Initializing_AI));
                robot           = SelfAwareness.BecomeSelfAware(this, "Galahad");
                newContextCache = new Gala.Data.Runtime.ContextCache();
                newContextCache.Initialize(this.ExecutiveFunctions);

                // Initialize Language Module
                InitializationStatusUpdated?.Invoke(this, new EngineInitializationEventArgs(50, EngineInitializationResources.Engine_Initializing_Language));
                this.User = new Galatea.Runtime.Services.User(_settings.DefaultUserName);
                chatbots  = new ChatbotManager(this.User, _settings);
                robot.LanguageModel.LoadChatbots(chatbots);

                // Add Text to Speech (even if silent)
                speech = new Galahad.Robotics.Speech.SpeechModule();
                speech.Initialize(robot.LanguageModel);
                speech.StaySilent = _settings.SpeechIsSilent;

                InitializationStatusUpdated?.Invoke(this, new EngineInitializationEventArgs(65, EngineInitializationResources.Engine_Initializing_Language_Speech));
                tts = new Galahad.Robotics.Speech.TextToSpeech(speech);
                tts.CurrentVoice = tts.GetVoice(0);
                InitializationStatusUpdated?.Invoke(this, new EngineInitializationEventArgs(80, EngineInitializationResources.Engine_Initializing_Language_Recognition));
                sr = new Galahad.Robotics.Speech.SpeechRecognition(speech);

                // Add Memory
                InitializationStatusUpdated?.Invoke(this, new EngineInitializationEventArgs(90, EngineInitializationResources.Engine_Initializing_Memory));
                robot.InitializeMemory(database);

                // Finalize
                database        = null;
                machine         = null;
                vision          = null;
                robot           = null;
                newContextCache = null;
                chatbots        = null;
                speech          = null;
                tts             = null;
                sr = null;
            }
            finally
            {
                if (database != null)
                {
                    database.Dispose();
                }
                if (machine != null)
                {
                    machine.Dispose();
                }
                if (vision != null)
                {
                    vision.Dispose();
                }
                if (robot != null)
                {
                    robot.Dispose();
                }
                if (newContextCache != null)
                {
                    newContextCache.Dispose();
                }
                if (chatbots != null)
                {
                    chatbots.Dispose();
                }
                if (speech != null)
                {
                    speech.Dispose();
                }
                if (sr != null)
                {
                    sr.Dispose();
                }
            }
        }
Example #2
0
        internal void Initialize()
        {
            Galatea.AI.Robotics.SensoryMotorSystem machine = null;
            VisualProcessor vision          = null;
            IRobot          robot           = null;
            ContextCache    newContextCache = null;
            IChatbotManager chatbots        = null;

            // Initialize Foundation Components
            try
            {
                machine = new Galatea.AI.Robotics.Machine();
                machine.Initialize(this);

                vision = new VisualProcessor(Settings.Default.ImagingSettings);
                vision.Initialize(this);

                // Become Self-Aware
                robot           = SelfAwareness.BecomeSelfAware(this, "Skynet");
                newContextCache = new ContextCache();
                newContextCache.Initialize(this.ExecutiveFunctions);
                // Verify that ContextCache is instantiated
                System.Diagnostics.Debug.Assert(ExecutiveFunctions.ContextCache != null);

                // Initialize Language Module
                this.User = new User(Settings.Default.DefaultUserName);
                chatbots  = new ChatbotManager();
                robot.LanguageModel.LoadChatbots(chatbots);

                var substitutions = new List <string>
                {
                    "I ,eye ",
                    ".,.  ",
                    "Ayuh,If you say so|false"
                };
                robot.LanguageModel.LoadSubstitutions(substitutions);

                _ai = robot;
            }
            catch
            {
                if (machine == null)
                {
                    throw new TeaArgumentNullException("machine");
                }
                if (vision == null)
                {
                    throw new TeaArgumentNullException("vision");
                }
                if (robot == null)
                {
                    throw new TeaArgumentNullException("robot");
                }
                if (newContextCache == null)
                {
                    throw new TeaArgumentNullException("newContextCache");
                }
                if (chatbots == null)
                {
                    throw new TeaArgumentNullException("chatbots");
                }
            }

            InitializeDatabase();
        }
Example #3
0
        private void Initialize()
        {
            IRobot robot = null;

            // Initialize Foundation Components
            try
            {
                machine = new Machine();
                machine.Initialize(this);

                vision = new VisualProcessor(Properties.Settings.Default.ImagingSettings);
                vision.Initialize(this);

                _dataAccessManager.Initialize(this);
                _dataAccessManager.InitializeMemoryBank();

                newContextCache = new ContextCache();
                newContextCache.Initialize(this.ExecutiveFunctions);

                // Verify that ContextCache is instantiated
                System.Diagnostics.Debug.Assert(ExecutiveFunctions.ContextCache != null);
            }
            catch
            {
                machine.Dispose();
                vision.Dispose();
                throw;
            }

            // Become Self-Aware
            robot = SelfAwareness.BecomeSelfAware(this, Properties.Settings.Default.ChatbotName);

            // Initialize Language Module
            this.User = new Galatea.Runtime.Services.User(Properties.Settings.Default.DefaultUserName);
            IChatbotManager chatbots = Gala.Dolly.Chatbots.ChatbotManager.GetChatbots(this.User);

            robot.LanguageModel.LoadChatbots(chatbots);

            var substitutions = new []
            {
                "I ,eye ",
                ".,.  ",
                "Ayuh,If you say so|false"
            };

            robot.LanguageModel.LoadSubstitutions(substitutions);

            speech = new Galatea.Speech.SpeechModule();
            speech.Initialize(robot.LanguageModel);
            speech.StaySilent = Properties.Settings.Default.SpeechIsSilent;

            // Add Text to Speech (even if silent)
            Galatea.Speech.ITextToSpeech tts5 = new Galatea.Speech.TextToSpeech5(speech);
            speech.TextToSpeech = tts5;

            // ********** WIN 10 ZIRA ********** //
            //SpeechLib.SpVoice spV = tts5.GetSpeechObject() as SpeechLib.SpVoice;

            int defaultVoiceIndex = Properties.Settings.Default.TextToSpeechDefaultVoiceIndex;

            try
            {
                Galatea.Speech.IVoice voice = tts5.GetVoice(defaultVoiceIndex);
                tts5.CurrentVoice = voice;
            }
            catch (Galatea.Speech.TeaSpeechException ex)
            {
                string msg = "Error loading Text to Speech.  Silencing Speech Module.";
                Galatea.Speech.TeaSpeechException ex1 = new Galatea.Speech.TeaSpeechException(msg, ex);
                Debugger.HandleTeaException(ex1, speech);

                Program.Console.SendResponse(msg);
                speech.StaySilent = true;
            }

            // Add Memory
            robot.InitializeMemory(_dataAccessManager);
        }