コード例 #1
0
 public void GotChatMsg(string msg, int player)                                  //called when someone writes a chat msg
 {
     try
     {
         if (msg.ToLower().IndexOf(".csai") == 0)
         {
             if (msg.ToLower().Substring(5, 1) == "*" || msg.ToLower().Substring(5, 1) == " " || msg.ToLower().Substring(5, 1) == Team.ToString())
             {
                 string[] splitchatline = msg.Split(" ".ToCharArray());
                 string   command       = splitchatline[1].ToLower();
                 if (VoiceCommands.Contains(command))
                 {
                     (VoiceCommands[command] as VoiceCommandHandler)(msg, splitchatline, player);
                 }
                 else
                 {
                     string helpstring = "CSAI commands available: help, ";
                     foreach (DictionaryEntry entry in VoiceCommands)
                     {
                         helpstring += entry.Key + ", ";
                     }
                     aicallback.SendTextMsg(helpstring, 0);
                     aicallback.SendTextMsg("Example: .csai" + Team + " showplaystyles", 0);
                 }
             }
         }
     }
     catch (Exception e)
     {
         logfile.WriteLine("Exception: " + e.ToString());
         aicallback.SendTextMsg("Exception: " + e.ToString(), 0);
     }
 }
コード例 #2
0
ファイル: VoiceForm.cs プロジェクト: threax/VoiceRecognition
        /// <summary>
        /// Fetch the configuration from the server, will execute using
        /// the thread pool, so this will return immediately with no result.
        /// Call after all configuration has been set.
        /// </summary>
        public async Task fetchConfigurationAsync()
        {
            //Try to download
            AppCommandSetCollectionResult commandResult = null;
            bool retry = true;

            while (retry)
            {
                try
                {
                    commandResult = await LoadCommands();

                    retry       = false;
                    foundConfig = true;
                }
                catch (Exception)
                {
                    Thread.Sleep(10000);
                }
            }

            this.Invoke(new Action(() =>
            {
                //Setup commands
                commands                    = new VoiceCommands(commandResult);
                commands.Restart           += commands_Restart;
                commands.PlaybackDeviceName = Config.PlaybackDeviceName;

                //Setup kinect
                recognizer = new KinectVoiceRecognizer(Config.Hotword, commands.getCommands(), Config.Sensitivity);
                recognizer.SensorConnected    += recognizer_SensorConnected;
                recognizer.SensorDisconnected += recognizer_SensorDisconnected;
                recognizer.initialize();
            }));
        }
コード例 #3
0
    // Need to attach voice commands to an object because
    // coroutines can only be called if attached to an object,
    private void SetUpVoiceCommands()
    {
        GameObject obj = new GameObject("Voice Commands");

        obj.AddComponent <VoiceCommands>();
        voiceCommands = obj.GetComponent <VoiceCommands>();
    }
コード例 #4
0
        /*
         * public static void EnableVoiceCommand(IEnumerable<Constants.Commands.VoiceCommandsEnum> voiceCommands)
         * {
         *  foreach (var command in voiceCommands)
         *  {
         *      EnableVoiceCommand(command);
         *  }
         * }
         */

        public static void DisableVoiceCommand(VoiceCommands command)
        {
            bool disabled = false;

            if (command == VoiceCommands.Start)
            {
                keywords.Remove(VoiceKeywords.Word_Start);
                disabled = true;
            }
            else if (command == VoiceCommands.Photo)
            {
                keywords.Remove(VoiceKeywords.Word_Photo);
                disabled = true;
            }
            else if (command == VoiceCommands.End)
            {
                keywords.Remove(VoiceKeywords.Word_End);
                disabled = true;
            }

            if (disabled)
            {
                RefreshKeywordRecognizer();
            }

            //if (keywords.Count == 0)
            //    keywordRecognizer.OnPhraseRecognized -= KeywordRecognizer_OnPhraseRecognized;
        }
コード例 #5
0
 /// <summary>
 /// LoadContent will be called only once before drawing and it's the place to load
 /// all of your content.
 /// </summary>
 public virtual void LoadContent()
 {
     frameNumber = Kinect.FramesCount;
     content     = ScreenManager.Game.Content;
     spriteBatch = ScreenManager.SpriteBatch;
     depthTex    = new Texture2D(screenManager.GraphicsDevice, 320, 240);
     font        = content.Load <SpriteFont>("SpriteFont1");
     MediaPlayer.Stop(); // stop current audio playback
     // generate a random valid index into Albums
     voiceCommands = ScreenManager.Kinect.voiceCommands;
     if (showAvatar)
     {
         userAvatar = new UserAvatar(ScreenManager.Kinect, content, ScreenManager.GraphicsDevice, spriteBatch);
         userAvatar.LoadContent();
     }
 }
コード例 #6
0
        private async void InstallVoiceCommands(List <VoiceCommand> lst)
        {
            VoiceCommands vcd = new VoiceCommands();

            vcd.CommandSet      = new VoiceCommandSet();
            vcd.CommandSet.lang = "en-us";
            vcd.CommandSet.Name = "HASS";

            vcd.CommandSet.Example = "Read command as shown";

            string prefix = "Please";

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            if (localSettings.Values.ContainsKey("VoicePrefix"))
            {
                prefix = (string)localSettings.Values["VoicePrefix"];
            }


            vcd.CommandSet.CommandPrefix = prefix;
            vcd.CommandSet.Command       = lst.ToArray();

            // Serialize to xml
            XmlSerializer ser = new XmlSerializer(typeof(VoiceCommands));
            string        xml;

            //StringWriter writer = new StringWriter();
            using (StringWriter writer = new Utf8StringWriter())
            {
                ser.Serialize(writer, vcd);
                xml = writer.ToString();
            }
            //xml = xml.Replace("utf-16", "utf-8");
            xml = xml.Replace("xsi:nil=\"true\"", string.Empty);

            // save XML in a Temp file
            StorageFolder tempFolder = ApplicationData.Current.TemporaryFolder;
            StorageFile   vcdFile    = await tempFolder.CreateFileAsync(@"VoiceCommands.xml", CreationCollisionOption.ReplaceExisting);

            await FileIO.WriteTextAsync(vcdFile, xml, Windows.Storage.Streams.UnicodeEncoding.Utf8);

            // Load temp file into cortana
            await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(vcdFile);
        }
コード例 #7
0
        public static void EnableVoiceCommand(VoiceCommands command)
        {
            bool enabled = false;

            if (command == VoiceCommands.Start)
            {
                // Command: Begin texture capture protocol
                // (i.e. start up photocapture process)
                keywords.Add(VoiceKeywords.Word_Start, () =>
                {
                    // ERROR TESTING -
                    CameraManager.StartTextureCapture();
                });

                enabled = true;
            }
            else if (command == VoiceCommands.Photo)
            {
                // Command: Take texture screenshot
                keywords.Add(VoiceKeywords.Word_Photo, () =>
                {
                    // ERROR TESTING -
                    CameraManager.CaptureTexture();
                });

                enabled = true;
            }
            else if (command == VoiceCommands.End)
            {
                // Command: End texture capture protocol and clean up
                keywords.Add(VoiceKeywords.Word_End, () =>
                {
                    // ERROR TESTING -
                    CameraManager.StopTextureCapture();
                });

                enabled = true;
            }

            if (enabled)
            {
                RefreshKeywordRecognizer();
            }
        }
コード例 #8
0
ファイル: GameScreen.cs プロジェクト: khaledosman/TVControl
        /// <summary>
        /// LoadContent will be called only once before drawing and it's the place to load
        /// all of your content.
        /// </summary>
        public virtual void LoadContent()
        {
            frameNumber    = Kinect.FramesCount;
            content        = ScreenManager.Game.Content;
            spriteBatch    = ScreenManager.SpriteBatch;
            PrimitiveBatch = new PrimitiveBatch(ScreenManager.GraphicsDevice);
            font           = content.Load <SpriteFont>("SpriteFont1");
            //   songs = MyExtension.LoadListContent<Song>(content, "Audio\\");
            //songsarray = songs.ToArray();
            // sampleMediaLibrary = new MediaLibrary();
            random = new Random();
            //MediaPlayer.Stop(); // stop current audio playback
            // generate a random valid index into Albums
            voiceCommands = ScreenManager.Kinect.voiceCommands;
            if (showAvatar)
            {
                userAvatar = new UserAvatar(ScreenManager.Kinect, content, ScreenManager.GraphicsDevice, spriteBatch);
                userAvatar.LoadContent();
            }

            depthTex = new Texture2D(screenManager.GraphicsDevice, 320, 240);
        }
コード例 #9
0
 public RegexCreator(VoiceCommands voiceCommand)
 {
     _voiceCommand = voiceCommand;
     _valuesList   = new Dictionary <string, List <string> >();
     StartExtract();
 }