0

私は、パラレルポートを介してリレーを制御するための単純な音声認識アプリケーションを使用していましたが、これが基本的なプログラムであり、動作するはずです。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Speech.Synthesis;
using Microsoft.Speech.Recognition;

namespace speechHardware
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create a new SpeechRecognitionEngine instance.
          var  sre = new SpeechRecognitionEngine();
          SpeechSynthesizer s = new SpeechSynthesizer();
          Console.WriteLine("starting recognizer.......");
          s.Speak("starting recognizer.");

          // Create a simple grammar that recognizes "light on", "light off", or "fan on","fan off".
            Choices colors = new Choices();
            Console.WriteLine("option list.......");
            colors.Add("light on");
            colors.Add("light off");
            colors.Add("fan on");
            colors.Add("fan off");

            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(colors);
            Console.WriteLine("starting grammer builder.......");

            // Create the actual Grammar instance, and then load it into the speech recognizer.
            Grammar g = new Grammar(gb);
            sre.LoadGrammar(g);

            // Register a handler for the SpeechRecognized event.
            sre.SpeechRecognized += SreSpeechRecognized;
            //sre.SetInputToWaveFile("C:\Users\Raghavendra\Documents\MATLAB\test.wav");
          sre.SetInputToDefaultAudioDevice();
            Console.WriteLine("input device recognised.......");         
            s.Speak("input device recognised.");
         sre.RecognizeAsync(RecognizeMode.Multiple);
            Console.ReadLine();
            Console.WriteLine("stopping recognizer.....");
            sre.RecognizeAsyncStop();

        }
        static void SreSpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            SpeechSynthesizer s = new SpeechSynthesizer();
            Console.WriteLine("\nSpeech Recognized: \t{0}" + e.Result.Confidence, e.Result.Text);

            if (e.Result.Confidence < 0.85)
                return;

            switch (e.Result.Text)
            {
                case "light on":
                    light(1);                    
                    s.Speak("the light has been turned on.");
                    break;
                case "light off":
                    light(0);
                    s.Speak("the light has been turned off.");
                    break;
                case "fan on":
                    fan(1);
                    s.Speak("the fan has been turned on.");
                    break;
                case "fan off":
                    fan(0);
                    s.Speak("the fan has been turned off.");
                    break;
                default:

                    break;
            }
        }
        static void light(int val)
        {
            Console.WriteLine("\nSpeech Recognized:light ");
        }

        static void fan(int val)
        {
            Console.WriteLine("\nSpeech Recognized: fan");
        }


    }
}

これは私の友人のコンピューターでは完全に機能しますが、私のコンピューターでは、私が話していることを認識しません。入力が得られていない可能性があります。どちらもほぼ同じ構成です。マイクも正常に機能しており、何が悪いのかわかりません。

Microsoft Speech Platform - Software Development Kit (SDK)、バージョン 10.2 (x86 エディション) をインストールしました Microsoft Speech Platform - Server Runtime、バージョン 10.2 (x86 エディション)

私を助けてください。

4

4 に答える 4

2

Microsoft.Speech.Recognition を System.Speech.Recognition に置き換えたところ、機能しました。

何が悪いのか理解できません。

于 2012-01-30T15:28:10.280 に答える
1

sre.RecognizeAsyncStop(); を呼び出しています。音声を認識する前に。async は非ブロックであるため、音声が認識されるまで待機しないことに注意してください。その行を削除すると、機能するはずです。

于 2012-01-17T13:56:09.637 に答える
0

あなたの友人は Windows XP を実行していて、あなたは Vista または 7 を実行していると思われます。Microsoft は、実際には OS パッケージの一部として音声認識機能を組み込んでいたと思いますが、XP ではそうではありませんでした。これは、インクルードを Microsoft から System に変更しなければならなかった理由に対する可能な答えかもしれません。

于 2012-05-31T22:04:46.760 に答える
0

より低い値を信頼に入れてみてください。マイクのノイズが多すぎるか、ミュートになっている可能性がありますか? :)

于 2012-01-17T12:53:24.690 に答える