質問

Windows 7 で正常に動作する System.Speech を使用した音声認識用のアプリを C# で作成しました。ただし、Windows 2003 (x86) で動作する同じアプリを作成した後です。

私のプログラミング環境:Windows 7 X64 Pro Visual Studio 2008

このアプリケーションをプログラミング環境で開発するために、次のものをインストールしました。

1.Microsoft Speech Platform - サーバー ランタイム (バージョン 10.1) (x86)

http://www.microsoft.com/downloads/details.aspx?FamilyID=674356C4-E742-4855-B3CC-FC4D5522C449&displaylang=en&displaylang=en

2.Microsoft 音声プラットフォーム - ソフトウェア開発キット (SDK) (バージョン 10.1) (x86)

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=4d36908b-3264-49ef-b154-f23bf7f44ef4

3.Microsoft Speech Platform - サーバー ランタイム言語 (バージョン 10.1)

(ここでは en-GB 用の SR をインストールしました)

http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=f704cd64-1dbf-47a7-ba49-27c5843a12d5

私のプログラムでは、System.Speech の代わりに Microsoft.Speech.Recognition を使用しました。

SDK ドキュメントからこのコードを貼り付けました。

using Microsoft.Speech.Recognition;

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
  public partial class Form1 : Form
  {
    public Form1()
    {
      InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {
      // Create a new SpeechRecognitionEngine instance.
      sre = new SpeechRecognitionEngine();

      // Create a simple grammar that recognizes “red”, “green”, or “blue”.
      Choices colors = new Choices();
      colors.Add("red");
      colors.Add("green");
      colors.Add("blue");

      GrammarBuilder gb = new GrammarBuilder();
      gb.Append(colors);

      // 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 += new EventHandler<SpeechRecognizedEventArgs>(sre_SpeechRecognized);
      sre.SetInputToDefaultAudioDevice();
      sre.RecognizeAsync(RecognizeMode.Multiple);
    }

    // Simple handler for the SpeechRecognized event.
    void sre_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
    {
      MessageBox.Show(e.Result.Text);
    }

    SpeechRecognitionEngine sre;
  }
}

また、プロジェクトのプロパティでプラットフォーム ターゲットを x86 に設定しました。コードはコンパイルされますが、実行またはデバッグすると認識が機能しません。私に何が欠けているのかわかりますか?

役に立ちましたか?

解決

エンジンを指定せずに音声認識エンジンを作成しています。en-GB エンジンをインストールしたので、 文化情報 (または 認識情報):

sre = new SpeechRecognitionEngine(new CultureInfo("en-GB")); 
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top