Esempio n. 1
0
 void doStop()
 {
     if (iTunesControl == null)
     {
         return;
     }
     // Stop track
     try
     {
         iTunesControl.Stop();
     }
     catch (COMException ex)
     {
         iTunesError(ex, "Could not stop in iTunes.");
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Process[] pname = Process.GetProcessesByName("iTunes");
            if (pname.Length == 0 || args.Length == 0) //iTunes process not found OR no arguments passed
            {
                Environment.Exit(1);
            }

            var app = new iTunesApp();

            switch (args[0].ToLower())
            {
            case "playpause":
                app.PlayPause();
                break;

            case "next":
                app.NextTrack();
                break;

            case "prev":
                app.PreviousTrack();
                break;

            case "stop":
                app.Stop();
                break;

            case "volup":
                app.SoundVolume = Math.Min(100, app.SoundVolume + 5);
                break;

            case "voldown":
                app.SoundVolume = Math.Max(0, app.SoundVolume - 5);
                break;
            }

            Environment.Exit(0);
        }
Esempio n. 3
0
        private void initRecognizer()
        {
            mRecognizerRule = new SpeechLib.SpInProcRecoContext();
            bool hit = false;

            foreach (SpObjectToken recoPerson in mRecognizerRule.Recognizer.GetRecognizers())
            {
                if (recoPerson.GetAttribute("Language") == "411")
                {
                    mRecognizerRule.Recognizer.Recognizer = recoPerson;
                    hit = true;
                    break;
                }
            }
            if (!hit)
            {
                MessageBox.Show("日本語認識が利用できません");
                Application.Exit();
            }

            mRecognizerRule.Recognizer.AudioInput = createMicrofon();

            if (mRecognizerRule.Recognizer.AudioInput == null)
            {
                MessageBox.Show("マイク初期化エラー");
                Application.Exit();
            }

            mRecognizerRule.Hypothesis +=
                delegate(int streamNumber, object streamPosition, SpeechLib.ISpeechRecoResult result)
            {
                string strText = result.PhraseInfo.GetText();
                textBox1.Text = strText;
            };
            mRecognizerRule.Recognition +=
                delegate(int streamNumber, object streamPosition, SpeechLib.SpeechRecognitionType srt, SpeechLib.ISpeechRecoResult isrr)
            {
                SpeechEngineConfidence confidence = isrr.PhraseInfo.Rule.Confidence;
                switch (confidence)
                {
                case SpeechEngineConfidence.SECHighConfidence:
                    label3.Text = "Confidence is High";
                    break;

                case SpeechEngineConfidence.SECNormalConfidence:
                    label3.Text = "Confidence is Normal";
                    break;

                case SpeechEngineConfidence.SECLowConfidence:
                    label3.Text   = "Confidence is Low";
                    textBox2.Text = "信頼性が低すぎます";
                    return;
                }
                string strText = isrr.PhraseInfo.GetText();
                //isrr.PhraseInfo.
                label4.Text = isrr.RecoContext.Voice.Volume.ToString();
                if (strText == "えんいー")
                {
                    Application.Exit();
                }

                if (itunes != null)
                {
                    switch (strText)
                    {
                    case "あいちゅーんず.つぎのきょく":
                    case "あいちゅーんず.つぎ":
                        itunes.NextTrack();
                        break;

                    case "あいちゅーんず.まえのきょく":
                    case "あいちゅーんず.まえ":
                        itunes.PreviousTrack();
                        break;

                    case "あいちゅーんず.いちじていし":
                        itunes.Pause();
                        break;

                    case "あいちゅーんず.ていし":
                        itunes.Stop();
                        break;

                    case "あいちゅーんず.さいせい":
                        itunes.Play();
                        break;

                    case "あいちゅーんず.しね":
                        itunes.Quit();
                        unhockiTunes();
                        break;

                    case "あいちゅーんず.しずかに":
                        itunes.SoundVolume = 50;
                        break;

                    case "あいちゅーんず.おおきく":
                        itunes.SoundVolume = 100;
                        break;

                    case "あいちゅーんず.らんだむ":
                        itunes.CurrentPlaylist.Shuffle = !itunes.CurrentPlaylist.Shuffle;
                        break;
                    }
                }
                else
                {
                    if (strText == "あいちゅーんず.おきろ")
                    {
                        initiTunes();
                    }
                }
                textBox2.Text = strText;
            };
            mRecognizerRule.StartStream +=
                delegate(int streamNumber, object streamPosition)
            {
                textBox1.Text = textBox2.Text = "";
            };
            mRecognizerRule.FalseRecognition +=
                delegate(int streamNumber, object streamPosition, SpeechLib.ISpeechRecoResult isrr)
            {
                textBox1.Text = textBox2.Text = label3.Text = "--Error!--";
            };

            mRecognizerGrammarRule = mRecognizerRule.CreateGrammar();
            mRecognizerGrammarRule.Reset();
            mRecognizerGrammarRuleGrammarRule = mRecognizerGrammarRule.Rules.Add("TopLevelRule", SpeechRuleAttributes.SRATopLevel | SpeechRuleAttributes.SRADynamic);

            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.おきろ");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.つぎのきょく");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.まえのきょく");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.つぎ");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.まえ");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.いちじていし");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.ていし");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.さいせい");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.しね");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.しずかに");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.おおきく");
            mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "あいちゅーんず.らんだむ");
            // mRecognizerGrammarRuleGrammarRule.InitialState.AddWordTransition(null, "えんいー");

            mRecognizerGrammarRule.Rules.Commit();
            mRecognizerGrammarRule.CmdSetRuleState("TopLevelRule", SpeechRuleState.SGDSActive);
        }