private void MmiC_Message(object sender, MmiEventArgs e)
        {
            Console.WriteLine(e.Message);
            var        doc        = XDocument.Parse(e.Message);
            var        com        = doc.Descendants("command").FirstOrDefault().Value;
            dynamic    json       = JsonConvert.DeserializeObject(com);
            double     confidence = Double.Parse((string)json.recognized[0].ToString());
            String     command    = (string)json.recognized[1].ToString();
            String     album      = (string)json.recognized[2].ToString();
            String     song       = (string)json.recognized[3].ToString();
            String     by         = (string)json.recognized[4].ToString();
            String     artist     = (string)json.recognized[5].ToString();
            String     genre      = (string)json.recognized[6].ToString();
            String     from       = (string)json.recognized[7].ToString();
            String     year       = (string)json.recognized[8].ToString();
            SearchItem item;
            float      volume;

            if (t.getSpeech() == true)
            {
                return;
            }

            if (confidence < 0.3)
            {
                t.Speak("Sentence not valid. Please try again");
            }

            // Using just a normal command
            else
            {
                switch (command)
                {
                case "HELP":
                    t.Speak("You can play or stop music, skip and go back, mute and unmute and play artists, genres and songs.");
                    break;

                case "QUIT":
                    t.Speak("Bye Bye");
                    Environment.Exit(0);
                    break;

                case "PLAY":
                    spotify.Play();
                    break;

                case "PAUSE":
                    spotify.Pause();
                    break;

                case "SKIP":
                    spotify.Skip();
                    break;

                case "BACK":
                    spotify.Previous();
                    spotify.Previous();
                    break;

                case "VDOWN":
                    volume = spotify.GetSpotifyVolume();
                    if (volume - 25 >= 0)
                    {
                        spotify.SetSpotifyVolume(volume - 25);
                    }
                    else
                    {
                        spotify.SetSpotifyVolume(0);
                    }
                    break;

                case "VUP":
                    volume = spotify.GetSpotifyVolume();
                    if (volume + 25 <= 100)
                    {
                        spotify.SetSpotifyVolume(volume + 25);
                    }
                    else
                    {
                        spotify.SetSpotifyVolume(100);
                    }
                    break;

                case "MUTE":
                    if (!spotify.IsSpotifyMuted())
                    {
                        spotify.Mute();
                    }
                    break;

                case "UNMUTE":
                    if (spotify.IsSpotifyMuted())
                    {
                        spotify.UnMute();
                    }
                    break;

                case "ADD":
                    String playlist1         = webSpotify.GetUserPlaylists(userId: "4lzrg4ac5nyj1f5bosl1pse1i").Items[0].Id;
                    Paging <PlaylistTrack> p = webSpotify.GetPlaylistTracks("4lzrg4ac5nyj1f5bosl1pse1i", playlist1);
                    for (var i = 0; i < p.Items.Count; i++)
                    {
                        if (p.Items[i].Track.Name.Equals(spotify.GetStatus().Track.TrackResource.Name))
                        {
                            t.Speak("This music is already in your playlist");
                            return;
                        }
                    }

                    ErrorResponse x = webSpotify.AddPlaylistTrack("4lzrg4ac5nyj1f5bosl1pse1i", playlist1, spotify.GetStatus().Track.TrackResource.Uri);
                    if (!x.HasError())
                    {
                        t.Speak("This music was added to your playlist");
                    }
                    break;

                case "LISTEN":
                    App.Current.Dispatcher.Invoke(() =>
                    {
                        if (by == "BY")
                        {
                            // I wanna listen {album} by {artist}
                            if (album != "EMP" && song == "EMP")
                            {
                                String query = album + "+" + artist;
                                item         = webSpotify.SearchItems(query, SearchType.Album);
                                if (item.Albums.Items.Count > 0)
                                {
                                    spotify.PlayURL(item.Albums.Items[0].Uri);
                                }
                                else
                                {
                                    t.Speak("There is no album from that artist");
                                }
                            }
                            // I wanna listen {song} by {artist}
                            else if (song != "EMP" && album == "EMP")
                            {
                                String query = song + "+" + artist;
                                item         = webSpotify.SearchItems(query, SearchType.Track);
                                if (item.Tracks.Items.Count > 0)
                                {
                                    spotify.PlayURL(item.Tracks.Items[0].Uri);
                                }
                                else
                                {
                                    t.Speak("There is no song with that name from that artist");
                                }
                            }
                            else
                            {
                                t.Speak("There is no album or song with that name from that artist");
                            }
                        }
                        else
                        {
                            // I wanna listen {artist} or {something} or {something I like}
                            if (artist != "EMP" && from == "EMP")
                            {
                                switch (artist)
                                {
                                case "LIKE":
                                    Paging <SimplePlaylist> playlists = webSpotify.GetUserPlaylists(userId: "4lzrg4ac5nyj1f5bosl1pse1i");
                                    int size = playlists.Items.Count;
                                    if (size == 0)
                                    {
                                        t.Speak("You don't have playlists.");
                                    }
                                    else
                                    {
                                        Random random           = new Random();
                                        int index               = random.Next(0, size);
                                        SimplePlaylist playlist = playlists.Items[index];
                                        if (playlist.Tracks.Total == 0 && size == 1)
                                        {
                                            t.Speak("Your playlist is empty.");
                                        }
                                        else
                                        {
                                            while (playlist.Tracks.Total == 0)
                                            {
                                                random   = new Random();
                                                index    = random.Next(0, size);
                                                playlist = playlists.Items[index];
                                            }
                                            spotify.PlayURL(playlists.Items[index].Uri);
                                        }
                                    }
                                    break;

                                case "SOMETHING":
                                    spotify.Play();
                                    break;

                                default:
                                    item = webSpotify.SearchItems(artist, SearchType.Artist);
                                    spotify.PlayURL(item.Artists.Items[0].Uri);
                                    break;
                                }
                            }
                            // I wanna listen {artist} from {year}
                            else if (artist != "EMP" && from != "EMP" && year != "EMP")
                            {
                                item = webSpotify.SearchItems(artist, SearchType.Artist | SearchType.Album);
                                if (item.Albums.Items.Count > 0)
                                {
                                    foreach (SimpleAlbum simple_album in item.Albums.Items)
                                    {
                                        String[] album_date = simple_album.ReleaseDate.Split('-');
                                        if (album_date[0] == year)
                                        {
                                            spotify.PlayURL(simple_album.Uri);
                                            return;
                                        }
                                    }
                                    t.Speak("There is no album from that artist on that year");
                                }
                                else
                                {
                                    t.Speak("There is no album from that artist on that year");
                                }
                            }
                            // I wanna listen {song}
                            else if (artist == "EMP" && genre == "EMP" && song != "EMP" && from == "EMP" && year == "EMP")
                            {
                                item = webSpotify.SearchItems(song, SearchType.Track);
                                if (item.Tracks.Items.Count > 0)
                                {
                                    spotify.PlayURL(item.Tracks.Items[0].Uri);
                                }
                                else
                                {
                                    t.Speak("There is no song with that name");
                                }
                            }
                            // I wanna listen {album}
                            else if (album != "EMP" && artist == "EMP" && genre == "EMP" && song == "EMP" && from == "EMP" && year == "EMP")
                            {
                                item = webSpotify.SearchItems(album, SearchType.Album);
                                if (item.Albums.Items.Count > 0)
                                {
                                    spotify.PlayURL(item.Albums.Items[0].Uri);
                                }
                                else
                                {
                                    t.Speak("There is no album with that name");
                                }
                            }
                            // I wanna listen {genre}
                            else if (artist == "EMP" && genre != "EMP" && song == "EMP" && album == "EMP" && from == "EMP" && year == "EMP")
                            {
                                item             = webSpotify.SearchItems(genre, SearchType.Album | SearchType.Track | SearchType.Playlist);
                                int results_size = item.Playlists.Items.Count;
                                if (results_size > 0)
                                {
                                    // Choose playlist randomly
                                    Random random = new Random();
                                    int index     = random.Next(0, results_size);
                                    spotify.PlayURL(item.Playlists.Items[index].Uri);
                                }
                                else
                                {
                                    t.Speak("There are no playlists with that genre");
                                }
                            }
                            else
                            {
                                t.Speak("I am very sorry but this command is not supported");
                            }
                        }
                    });
                    break;

                default:
                    t.Speak("I am very sorry but this command is not supported");
                    break;
                }
            }
        }
Beispiel #2
0
        private void MmiC_Message(object sender, MmiEventArgs e)
        {
            Console.WriteLine(e.Message);
            var     doc  = XDocument.Parse(e.Message);
            var     com  = doc.Descendants("command").FirstOrDefault().Value;
            dynamic json = JsonConvert.DeserializeObject(com);

            InputSimulator inputsim = new InputSimulator();

            double confidence = Double.Parse((string)json.recognized[0].ToString());

            String command = (string)json.recognized[1].ToString();

            String command2 = (string)json.recognized[2].ToString();

            String details = (string)json.recognized[3].ToString();

            String weapon = (string)json.recognized[4].ToString();


            if (t.getSpeech() == true)
            {
                return;
            }

            if (confidence < 0.3)
            {
                t.Speak("Desculpe, pode repetir?");
            }

            else
            {
                textbox_output_mmi.Text = " " + command + " " + command2 + " " + details + " " + weapon + " ";

                switch (command)
                {
                // SPEECH
                // QUANTOS/QUANTAS
                case "HOWMANY":
                    switch (command2)
                    {
                    // RONDAS
                    case "ROUNDS":
                    {
                        switch (details)
                        {
                        // FALTAM PARA O FIM DO JOGO
                        case "LEFT":
                        {
                            // GET ROUNDS LEFT UNTIL END OF GAME

                            t.Speak("Faltam " + (30 - gamestate.round_number) + " rondas");
                            break;
                        }

                        // FALTAM PARA O INTERVALO
                        case "LEFT_HALF":
                        {
                            // GET ROUNDS LEFT UNTIL HALFTIME
                            if (gamestate.round_number >= 15)
                            {
                                t.Speak(" Já estás na segunda parte do jogo!");
                            }
                            else if (gamestate.round_number == 0)
                            {
                                t.Speak(" O jogo ainda não começou!");
                            }
                            else
                            {
                                t.Speak("Faltam " + (15 - gamestate.round_number) + " rondas para o intervalo");
                            }
                            break;
                        }
                        }
                        break;
                    }

                    // BALAS TENHO
                    case "BULLETS":
                    {
                        t.Speak(" Tens " + gamestate.bullets + " balas restantes");
                        if (gamestate.bullets <= (0.1 * gamestate.max_bullets))
                        {
                            t.Speak(" Aconselho-te a recarregar.");
                        }
                        break;
                    }

                    // MORTES NUMA RONDA
                    case "KILLS":
                    {
                        switch (details)
                        {
                        case "HAVE_ROUND":
                        {
                            t.Speak("Mataste " + gamestate.roundkills + " nesta ronda");
                            break;
                        }

                        case "HAVE":
                        {
                            t.Speak("Tens um total de " + gamestate.total_kills + " mortes");
                            break;
                        }
                        }

                        break;
                    }

                    // TOTAL DE OBITOS
                    case "DEATHS":
                    {
                        t.Speak("Morreste " + gamestate.total_deaths);
                        break;
                    }

                    // ESPETADORES
                    case "SPECTATORES":
                    {
                        t.Speak("Temos no total " + gamestate.spectators + "espetadores");
                        break;
                    }
                    }
                    break;

                // QUANTO/QUANTA
                case "HOWMUCH":
                    switch (command2)
                    {
                    // DINHEIRO
                    case "MONEY":
                    {
                        switch (details)
                        {
                        // TENHO
                        case "HAVE":
                        {
                            t.Speak("Tens " + gamestate.money + " dólares.");
                            break;
                        }

                        // CUSTA UM/UMA
                        case "COST":
                        {
                            switch (weapon)
                            {
                            // AK-47
                            case "AK47":
                            {
                                t.Speak(" Uma AK-47 custa " + Prices.ak47 + " dólares");
                                break;
                            }

                            // DEAGLE
                            case "DEAGLE":
                            {
                                t.Speak(" Uma Desert Eagle custa " + Prices.deagle + " dólares");
                                break;
                            }

                            // AWP
                            case "AWP":
                            {
                                t.Speak(" Uma AWP custa " + Prices.awp + " dólares");
                                break;
                            }

                            // DEFUSE
                            case "DEFUSE":
                            {
                                t.Speak(" O Defuse custa " + Prices.defuse + " dólares");
                                break;
                            }

                            // COLETE CAPACETE
                            case "KELVAR_CAP":
                            {
                                t.Speak(" O Colete e o capacete custa " + Prices.kelvar_cap + " dólares");
                                break;
                            }

                            // P250
                            case "P250":
                            {
                                t.Speak(" Uma P250 custa " + Prices.p250 + " dólares");
                                break;
                            }

                            // MP7
                            case "MP7":
                            {
                                t.Speak(" Uma MP7 custa " + Prices.mp7 + " dólares");
                                break;
                            }

                            // UMP45
                            case "UMP45":
                            {
                                t.Speak(" Uma UMP45 custa " + Prices.ump45 + " dólares");
                                break;
                            }
                            }
                            break;
                        }

                        // FALTA-ME PARA COMPRAR UMA
                        case "LEFT":
                        {
                            switch (weapon)
                            {
                            // AK-47
                            case "AK47":
                            {
                                if (gamestate.money < Prices.ak47)
                                {
                                    t.Speak(" Faltam-te " + (Prices.ak47 - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Consegues comprar uma A K 47 e sobrar " + (gamestate.money - Prices.ak47) + " dólares.");
                                }
                                break;
                            }

                            // DEAGLE
                            case "DEAGLE":
                            {
                                if (gamestate.money < Prices.deagle)
                                {
                                    t.Speak(" Faltam-te " + (Prices.deagle - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Consegues comprar uma Deagle e sobrar " + (gamestate.money - Prices.deagle) + " dólares.");
                                }
                                break;
                            }

                            // AWP
                            case "AWP":
                            {
                                if (gamestate.money < Prices.awp)
                                {
                                    t.Speak(" Faltam-te " + (Prices.awp - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Consegues comprar uma A W P e sobrar " + (gamestate.money - Prices.awp) + " dólares.");
                                }
                                break;
                            }

                            // DEFUSE
                            case "DEFUSE":
                            {
                                if (gamestate.money < Prices.defuse)
                                {
                                    t.Speak(" Faltam-te " + (Prices.defuse - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Consegues comprar o Defuse e sobrar " + (gamestate.money - Prices.defuse) + " dólares.");
                                }
                                break;
                            }

                            // COLETE CAPACETE
                            case "KELVAR_CAP":
                            {
                                if (gamestate.money < Prices.kelvar_cap)
                                {
                                    t.Speak(" Faltam-te " + (Prices.kelvar_cap - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Consegues comprar o Colete e capacete e sobrar " + (gamestate.money - Prices.kelvar_cap) + " dólares.");
                                }
                                break;
                            }

                            // P250
                            case "P250":
                            {
                                if (gamestate.money < Prices.p250)
                                {
                                    t.Speak(" Faltam-te " + (Prices.p250 - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Consegues comprar uma P250 e sobrar " + (gamestate.money - Prices.p250) + " dólares.");
                                }
                                break;
                            }

                            // MP7
                            case "MP7":
                            {
                                if (gamestate.money < Prices.mp7)
                                {
                                    t.Speak(" Faltam-te " + (Prices.mp7 - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Consegues comprar uma M P 7 e sobrar " + (gamestate.money - Prices.mp7) + " dólares.");
                                }
                                break;
                            }

                            // UMP45
                            case "UMP45":
                            {
                                if (gamestate.money < Prices.ump45)
                                {
                                    t.Speak(" Faltam-te " + (Prices.ump45 - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Consegues comprar uma U M P 45 e sobrar " + (gamestate.money - Prices.ump45) + " dólares.");
                                }
                                break;
                            }
                            }
                            break;
                        }
                        }
                        break;
                    }

                    // VIDA
                    case "HEALTH":
                    {
                        switch (details)
                        {
                        // TENHO
                        case "HAVE":
                        {
                            t.Speak("Tens " + gamestate.health + "pontos de vida");
                            break;
                        }
                        }
                        break;
                    }

                    // ARMADURA
                    case "ARMOUR":
                    {
                        switch (details)
                        {
                        // TENHO
                        case "HAVE":
                        {
                            t.Speak("Tens " + gamestate.armour + "pontos de armadura");
                            break;
                        }
                        }
                        break;
                    }
                    }
                    break;

                // TENHO
                case "HAVE":
                {
                    switch (command2)
                    {
                    //DINHEIRO
                    case "MONEY":
                    {
                        switch (details)
                        {
                        //SUFICIENTE PARA COMPRAR UM/UMA
                        case "ENOUGH_FOR":
                        {
                            switch (weapon)
                            {
                            // AK-47
                            case "AK47":
                            {
                                if (gamestate.money < Prices.ak47)
                                {
                                    t.Speak(" Não, faltam-te" + (Prices.ak47 - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Tens dinehiro para comprar uma AK-47 e sobrar " + (gamestate.money - Prices.ak47) + " dólares.");
                                }
                                break;
                            }

                            // DEAGLE
                            case "DEAGLE":
                            {
                                if (gamestate.money < Prices.deagle)
                                {
                                    t.Speak(" Não, faltam-te " + (Prices.deagle - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Tens dinehiro para comprar uma Deagle e sobrar " + (gamestate.money - Prices.deagle) + " dólares.");
                                }
                                break;
                            }

                            // AWP
                            case "AWP":
                            {
                                if (gamestate.money < Prices.awp)
                                {
                                    t.Speak("Não, faltam-te " + (Prices.awp - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Tens dinehiro para comprar uma AWP e sobrar " + (gamestate.money - Prices.awp) + " dólares.");
                                }
                                break;
                            }

                            // DEFUSE
                            case "DEFUSE":
                            {
                                if (gamestate.money < Prices.defuse)
                                {
                                    t.Speak("Não, faltam-te " + (Prices.defuse - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Tens dinehiro para comprar o Defuse e sobrar " + (gamestate.money - Prices.defuse) + " dólares.");
                                }
                                break;
                            }

                            // COLETE CAPACETE
                            case "KELVAR_CAP":
                            {
                                if (gamestate.money < Prices.kelvar_cap)
                                {
                                    t.Speak("Não, faltam-te " + (Prices.kelvar_cap - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Tens dinehiro para comprar o Colete e Capacete e sobrar " + (gamestate.money - Prices.kelvar_cap) + " dólares.");
                                }
                                break;
                            }

                            // P250
                            case "P250":
                            {
                                if (gamestate.money < Prices.p250)
                                {
                                    t.Speak("Não, faltam-te " + (Prices.p250 - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Tens dinehiro para comprar uma P250 e sobrar " + (gamestate.money - Prices.p250) + " dólares.");
                                }
                                break;
                            }

                            // MP7
                            case "MP7":
                            {
                                if (gamestate.money < Prices.mp7)
                                {
                                    t.Speak("Não, faltam-te " + (Prices.mp7 - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Tens dinehiro para comprar uma M P 7 e sobrar " + (gamestate.money - Prices.mp7) + " dólares.");
                                }
                                break;
                            }

                            // UMP45
                            case "UMP45":
                            {
                                if (gamestate.money < Prices.ump45)
                                {
                                    t.Speak("Não, faltam-te " + (Prices.ump45 - gamestate.money) + " dólares");
                                }
                                else
                                {
                                    t.Speak(" Tens dinehiro para comprar uma U M P 45 e sobrar " + (gamestate.money - Prices.ump45) + " dólares.");
                                }
                                break;
                            }
                            }
                            break;
                        }
                        }
                        break;
                    }
                    }
                    break;
                }

                // COMPRA-ME UM/UMA
                case "BUY_ME":
                {
                    switch (weapon)
                    {
                    // AK-47
                    case "AK47":
                    {
                        if (gamestate.money < Prices.ak47)
                        {
                            t.Speak(" Não consigo, faltam-te" + (Prices.ak47 - gamestate.money) + " dólares");
                        }
                        else
                        {
                            // CÓDIGO PARA DAR INPUT DA TECLA: VK_6 ( Tecla 6 do teclado )
                            inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_6);

                            t.Speak(" Compraste uma A K 47 e sobraram " + (gamestate.money - Prices.ak47) + " dólares.");
                        }
                        break;
                    }

                    // DEAGLE
                    case "DEAGLE":
                    {
                        if (gamestate.money < Prices.deagle)
                        {
                            t.Speak(" Não consigo, faltam-te " + (Prices.deagle - gamestate.money) + " dólares");
                        }
                        else
                        {
                            // CÓDIGO PARA DAR INPUT DA TECLA: VK_8 ( Tecla 8 do teclado )
                            inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_8);

                            t.Speak(" Compraste uma Deagle e sobraram " + (gamestate.money - Prices.deagle) + " dólares.");
                        }
                        break;
                    }

                    // AWP
                    case "AWP":
                    {
                        if (gamestate.money < Prices.awp)
                        {
                            t.Speak("Não consigo, faltam-te " + (Prices.awp - gamestate.money) + " dólares");
                        }
                        else
                        {
                            // CÓDIGO PARA DAR INPUT DA TECLA: VK_7 ( Tecla 7 do teclado )
                            inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_7);

                            t.Speak(" Compraste uma A W P e sobraram " + (gamestate.money - Prices.awp) + " dólares.");
                        }
                        break;
                    }

                    // DEFUSE
                    case "DEFUSE":
                    {
                        if (gamestate.money < Prices.defuse)
                        {
                            t.Speak("Não consigo, faltam-te " + (Prices.defuse - gamestate.money) + " dólares");
                        }
                        else
                        {
                            // CÓDIGO PARA DAR INPUT DA TECLA: VK_9 ( Tecla 9 do teclado )
                            inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_9);

                            t.Speak(" Compraste o Defuse e sobraram " + (gamestate.money - Prices.defuse) + " dólares.");
                        }
                        break;
                    }

                    // COLETE CAPACETE
                    case "KELVAR_CAP":
                    {
                        if (gamestate.money < Prices.kelvar_cap)
                        {
                            t.Speak("Não consigo, faltam-te " + (Prices.kelvar_cap - gamestate.money) + " dólares");
                        }
                        else
                        {
                            // CÓDIGO PARA DAR INPUT DA TECLA: VK_0 ( Tecla 0 do teclado )
                            inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_0);

                            t.Speak(" Compraste o Colete e capacete e sobraram " + (gamestate.money - Prices.kelvar_cap) + " dólares.");
                        }
                        break;
                    }

                    // P250
                    case "P250":
                    {
                        if (gamestate.money < Prices.p250)
                        {
                            t.Speak("Não consigo, faltam-te " + (Prices.p250 - gamestate.money) + " dólares");
                        }
                        else
                        {
                            // CÓDIGO PARA DAR INPUT DA TECLA: VK_P ( Tecla P do teclado )
                            inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_P);

                            t.Speak(" Compraste uma P250 e sobraram " + (gamestate.money - Prices.p250) + " dólares.");
                        }
                        break;
                    }

                    // MP7
                    case "MP7":
                    {
                        if (gamestate.money < Prices.mp7)
                        {
                            t.Speak("Não consigo, faltam-te " + (Prices.mp7 - gamestate.money) + " dólares");
                        }
                        else
                        {
                            // CÓDIGO PARA DAR INPUT DA TECLA: VK_H ( Tecla H do teclado )
                            inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_H);

                            t.Speak(" Compraste uma M P 7 e sobraram " + (gamestate.money - Prices.mp7) + " dólares.");
                        }
                        break;
                    }

                    // UMP45
                    case "UMP45":
                    {
                        if (gamestate.money < Prices.ump45)
                        {
                            t.Speak("Não consigo, faltam-te " + (Prices.ump45 - gamestate.money) + " dólares");
                        }
                        else
                        {
                            // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                            inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_K);

                            t.Speak(" Compraste uma U M P 45 e sobraram " + (gamestate.money - Prices.ump45) + " dólares.");
                        }
                        break;
                    }
                    }
                    break;
                }

                // ABRE-ME O CSGO
                case "OPEN_CSGO":
                {
                    t.Speak(" Abrindo o Counter Strike ");
                    Process.Start(@"C:\Program Files (x86)\Steam\Steam.exe", "-applaunch 730 -console +exec autoexec +exec autoexec");
                    break;
                }

                // GESTURES
                // AGACHAR
                case "CROUCH":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyDown(VirtualKeyCode.LCONTROL);
                    Thread.Sleep(1000);

                    break;
                }

                // DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB DAB
                case "DAB":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_Y);
                    Thread.Sleep(100);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_D);
                    Thread.Sleep(50);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_A);
                    Thread.Sleep(50);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_B);
                    Thread.Sleep(50);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.RETURN);
                    Thread.Sleep(50);
                    break;
                }

                // CHEERS
                case "HEY":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_X);
                    Thread.Sleep(25);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_3);
                    break;
                }

                // AGUENTA ESTE SÍTIO
                case "HOLD":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_Z);
                    Thread.Sleep(25);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_4);
                    break;
                }

                // EQUIPA!
                case "TEAM":
                {
                    switch (command2)
                    {
                    //AGUENTEM ESTE SÍTIO
                    case "HOLD":
                    {
                        // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                        inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_X);
                        Thread.Sleep(25);
                        inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_3);
                        break;
                    }

                    // EXCELENTE!
                    case "HEY":
                    {
                        // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                        inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_Z);
                        Thread.Sleep(25);
                        inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_4);
                        break;
                    }
                    }
                    break;
                }

                // RECARREGA
                case "RELOAD":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_R);
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }
        private void MmiC_Message(object sender, MmiEventArgs e)
        {
            Console.WriteLine(e.Message);
            var     doc  = XDocument.Parse(e.Message);
            var     com  = doc.Descendants("command").FirstOrDefault().Value;
            dynamic json = JsonConvert.DeserializeObject(com);

            InputSimulator inputsim = new InputSimulator();

            double confidence = Double.Parse((string)json.recognized[0].ToString());

            String command = (string)json.recognized[1].ToString();

            /*
             * String command2 = (string)json.recognized[2].ToString();
             *
             * String details = (string)json.recognized[3].ToString();
             *
             * String weapon = (string)json.recognized[4].ToString();
             */

            if (t.getSpeech() == true)
            {
                return;
            }

            if (confidence < 0.3)
            {
                t.Speak("Desculpe, pode repetir?");
            }

            else
            {
                switch (command)
                {
                case "CROUCH":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyDown(VirtualKeyCode.LCONTROL);
                    Thread.Sleep(1000);

                    break;
                }

                case "DAB":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_Y);
                    Thread.Sleep(100);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_D);
                    Thread.Sleep(50);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_A);
                    Thread.Sleep(50);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_B);
                    Thread.Sleep(50);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.RETURN);
                    Thread.Sleep(50);
                    break;
                }

                case "HEY":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_X);
                    Thread.Sleep(25);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_3);
                    break;
                }

                case "HOLD":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_Z);
                    Thread.Sleep(25);
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_4);
                    break;
                }

                case "RELOAD":
                {
                    // CÓDIGO PARA DAR INPUT DA TECLA: VK_K ( Tecla K do teclado )
                    inputsim.Keyboard.KeyPress(VirtualKeyCode.VK_R);
                    break;
                }

                default:
                {
                    break;
                }
                }
            }
        }