예제 #1
0
        private async void Sp(object sender, RoutedEventArgs e)
        {
            try
            {
                if (sender == null)
                {
                }
                if (e == null)
                {
                }

                _recoWithUi = new SpeechRecognizerUI();
                _recoWithUi.Settings.ReadoutEnabled   = false;
                _recoWithUi.Settings.ShowConfirmation = false;
                _recoWithUi.Settings.ExampleText      = "";
                string[] b = _vita.GetAllCommands();
                _recoWithUi.Recognizer.Grammars.AddGrammarFromList("frenchNumbers", b);

                IEnumerable <SpeechRecognizerInformation> frenchRecognizers = from recognizerInfo in InstalledSpeechRecognizers.All
                                                                              where recognizerInfo.Language == "ru-RU"
                                                                              select recognizerInfo;

                _recoWithUi.Recognizer.SetRecognizer(frenchRecognizers.ElementAt(0));
                SpeechRecognitionUIResult recoResult = await _recoWithUi.RecognizeWithUIAsync();

                //SpeechSynthesizer synth = new SpeechSynthesizer();
                //await synth.SpeakTextAsync(recoResult.RecognitionResult.Text);
                MoonPadTcpClient.Send(recoResult.RecognitionResult.Text);
                _fl = 1;
            }
            catch (Exception ex)
            {
                _fl = 1;
            }
        }
예제 #2
0
        private void image_MouseLeftButtonUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            if (_press != "sp.png")
            {
                _press       = "sp.png";
                _release     = "sr.png";
                image.Source = new BitmapImage(new Uri("/Resources/" + _release, UriKind.RelativeOrAbsolute));
                try
                {
                    byte[] bytes = BitConverter.GetBytes(-1 * Convert.ToInt32(textBox.Text));
                    MoonPadTcpClient.Hostname = bytes[3] + "." + bytes[2] + "." + bytes[1] + "." + bytes[0];
                    MoonPadTcpClient.Port     = textBox1.Text;
                    MoonPadTcpClient.Connect();
                }
                catch
                {
                    // Ignored
                }
                return;
            }

            image.Source = new BitmapImage(new Uri("/Resources/" + _release, UriKind.RelativeOrAbsolute));

            if (_fl == -1)
            {
                MoonPadTcpClient.Send("phone" + DateTime.Now.Day + DateTime.Now.Hour + DateTime.Now.Minute +
                                      DateTime.Now.Second + DateTime.Now.Millisecond);
                _fl = 1;
            }
            else if (_fl == 1)
            {
                _fl = 0;

                Sp(sender, e);
            }
        }