2009-04-19 8 views
0

私はプロジェクトを実行しようとすると、私は次のエラーを取得しています:C#音声認識VISTA問題

A timeout occurred starting the SAPI Server. 

System.InvalidOperationException was unhandled 
Message="A timeout occurred starting the SAPI Server." 
Source="System.Speech" 
StackTrace: 
at System.Speech.Internal.SapiInterop.SapiRecognizer..ctor(RecognizerType type) 
at System.Speech.Recognition.SpeechRecognizer..ctor() 
at testdan.Form1..ctor() in C:\Users\Dany\Documents\Visual Studio 2008\Projects\testdan\testdan\Form1.cs:line 17 
at testdan.Program.Main() in C:\Users\Dany\Documents\Visual Studio 2008\Projects\testdan\testdan\Program.cs:line 18 
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
at System.Threading.ThreadHelper.ThreadStart() 

Form1のコード:

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; 
using System.Speech.Recognition; 
using System.Threading; 


namespace testdan 
{ 
    public partial class Form1 : Form 
    { 
     SpeechRecognizer rec = new SpeechRecognizer(); 

     public Form1() 
     { 
      InitializeComponent(); 
      rec.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(rec_SpeechRecognized); 
     } 

     void rec_SpeechRecognized(object sender, SpeechRecognizedEventArgs e) 
     { 

      lblLetter.Text = e.Result.Text; 
      MessageBox.Show(e.Result.Text); 
     } 

     void Form1_Load(object sender, EventArgs e) 
     { 
      var c = new Choices(); 
      c.Add("close"); 
      c.Add("stop"); 
      c.Add("pause"); 
      var gb = new GrammarBuilder(c); 
      var g = new Grammar(gb); 
      rec.LoadGrammar(g); 
      rec.Enabled = true; 
     } 

    } 
} 

答えて

0

おそらく、SAPIを使用するドライバーが不足していますか?そのため、ロード中にタイムアウトする可能性があります。

0

私もそれを見ました。スタートメニューから手動でデスクトップレコグナイザを起動しても正常に動作するコードを実行しても、共有レコグナイザが自動的にロードされていないようです。

0

WSR UIが表示されるまでどれくらい時間がかかりますか?私は、WSR UIの表示に通常よりも時間がかかり、プロキシがタイムアウトしている可能性があると考えています。

例外をキャッチして、コンストラクタを再試行してみてください。運があれば、WSR UIは引き続きアップし、コンストラクタを完成することができます。