From: Roger Frost on 16 Dec 2009 01:51 Hello, I'm having a problem getting a Grammar object loaded successfully for dictation. I'm trying this on Server 2003 SP2 with UCMA 2.0 and WindowsXP SP3 with Speech SDK 5.1 (both with VS2008, .Net 3.5), the exception messages are a little different, but are basically the same. I'll post the details of each one after my signature. Ultimately I need the solution for the Server/UCMA system, but since Microsoft.Speech and System.Speech are basically the same, I've been trying to debug on both systems as I'm sure a solution for one will work on the other. Same code for both machines, the only difference is "using Microsoft.Speech.Recognition;" vs. "using System.Speech.Recognition" Code (I appologize for the line breaks): this.engine = new SpeechRecognitionEngine(Application.CurrentCulture); this.engine.SpeechDetected += new EventHandler<SpeechDetectedEventArgs>(engine_SpeechDetected); this.engine.SpeechHypothesized += new EventHandler<SpeechHypothesizedEventArgs>(engine_SpeechHypothesized); this.engine.SpeechRecognitionRejected += new EventHandler<SpeechRecognitionRejectedEventArgs>(engine_SpeechRecognitionRejected); this.engine.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(engine_SpeechRecognized); GrammarBuilder dictaphoneGB = new GrammarBuilder(); dictaphoneGB.Culture = Application.CurrentCulture; GrammarBuilder dictation = new GrammarBuilder(); dictation.Culture = Application.CurrentCulture; dictation.AppendDictation(); dictaphoneGB.Append(new SemanticResultKey("StartDictation", new SemanticResultValue("Start Dictation", true))); dictaphoneGB.Append(new SemanticResultKey("dictationInput", dictation)); dictaphoneGB.Append(new SemanticResultKey("EndDictation", new SemanticResultValue("Stop Dictation", false))); GrammarBuilder spellingGB = new GrammarBuilder(); spellingGB.Culture = Application.CurrentCulture; GrammarBuilder spelling = new GrammarBuilder(); spelling.Culture = Application.CurrentCulture; spelling.AppendDictation("spelling"); spellingGB.Append(new SemanticResultKey("StartSpelling", new SemanticResultValue("Start Spelling", true))); spellingGB.Append(new SemanticResultKey("spellingInput", spelling)); spellingGB.Append(new SemanticResultKey("StopSpelling", new SemanticResultValue("Stop Spelling", true))); GrammarBuilder both = GrammarBuilder.Add((GrammarBuilder)new SemanticResultKey("Dictation", dictaphoneGB), (GrammarBuilder)new SemanticResultKey("Spelling", spellingGB)); both.Culture = Application.CurrentCulture; Grammar grammar = new Grammar(both); grammar.Enabled = true; grammar.Name = "Dictaphone and Spelling "; this.engine.LoadGrammar(grammar); // Exception thrown here /Code This is based on the Microsoft example at: http://msdn.microsoft.com/en-us/library/ms576566.aspx and http://msdn.microsoft.com/en-us/library/system.speech.recognition.grammarbuilder.debugshowphrases.aspx Basically, what I need to do is get the functionality of the DictationGrammar class in a "long handed way" out of the Grammar class, the reason is because Microsoft.Speech.Recognition doesn't contain the DictationGrammar class (this seems to be the only main difference between the two namespaces/assemblies from a developer's point of view.) If I can just get past that exception I should be good to go. And I will settle for a grxml, a cfg, a runtime solution, anything that can dictate speech in english using SAPI or UCMA. Because anything is better than where I am now, trial and error over and over for 2 days. I appreciate any guidance I can get, I've posted simpler problems on two different Speech groups with little response. Also information on the web is virtually nil for this topic. So I ask one question...how good are you? :) Thanks for reading folks, Roger Frost /////////////////////////////////////////////////////////////////////////////////// WindowsXP SP3 with Speech SDK 5.1 System.FormatException was unhandled Message="A rule reference to an imported grammar cannot be resolved." Source="System.Speech" StackTrace: at System.Speech.Recognition.RecognizerBase.LoadSapiGrammarFromCfg(SapiGrammar sapiGrammar, Grammar grammar, Uri baseUri, Boolean enabled, Single weight, Int32 priority) at System.Speech.Recognition.RecognizerBase.LoadSapiGrammar(Grammar grammar, SapiGrammar sapiGrammar, Boolean enabled, Single weight, Int32 priority) at System.Speech.Recognition.RecognizerBase.LoadGrammar(Grammar grammar) at System.Speech.Recognition.SpeechRecognitionEngine.LoadGrammar(Grammar grammar) at STT_TTS.SpeechToText.SpeechToTextForm..ctor() in D:\Projects\RentACoder.com\STT+TTS Application\STT+TTS\SpeechToText\SpeechToTextForm.cs:line 37 at STT_TTS.MainForm.speechToTextButton_Click(Object sender, EventArgs e) in D:\Projects\RentACoder.com\STT+TTS Application\STT+TTS\STT+TTS\MainForm.cs:line 71 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at STT_TTS.Program.Main() in D:\Projects\RentACoder.com\STT+TTS Application\STT+TTS\STT+TTS\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() InnerException: System.Runtime.InteropServices.COMException Message="Exception from HRESULT: 0x80045024" Source="System.Speech" ErrorCode=-2147200988 StackTrace: at System.Speech.Internal.SapiInterop.SapiProxy.MTAThread.Invoke2(VoidDelegate pfn) at System.Speech.Internal.SapiInterop.SapiGrammar.LoadCmdFromMemory(IntPtr grammar, SPLOADOPTIONS options) at System.Speech.Recognition.RecognizerBase.LoadSapiGrammarFromCfg(SapiGrammar sapiGrammar, Grammar grammar, Uri baseUri, Boolean enabled, Single weight, Int32 priority) InnerException: /////////////////////////////////////////////////////////////////////////////////// Server 2003 SP2 (32-bit) with UCMA 2.0 SDK System.IO.FileNotFoundException was unhandled Message="Cannot find grammar referenced by this grammar." Source="Microsoft.Speech" StackTrace: at Microsoft.Speech.Recognition.MemoryGrammarContent.Load(SapiGrammar sapiGrammar, Boolean enabled, Single weight, Int32 priority) at Microsoft.Speech.Recognition.GrammarContent.Load(SapiGrammar sapiGrammar) at Microsoft.Speech.Recognition.Grammar.Load(SapiGrammar sapiGrammar, IRecognizerInternal recognizer) at Microsoft.Speech.Recognition.RecognizerBase.LoadGrammarIntoSapi(Grammar grammar) at Microsoft.Speech.Recognition.RecognizerBase.LoadGrammar(Grammar grammar) at Microsoft.Speech.Recognition.SpeechRecognitionEngine.LoadGrammar(Grammar grammar) at STT_TTS.SpeechToText.SpeechToTextForm..ctor() in C:\Documents and Settings\Administrator\Desktop\STT+TTS Application\STT+TTS\SpeechToText\SpeechToTextForm.cs:line 61 at STT_TTS.MainForm.speechToTextButton_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\Desktop\STT+TTS Application\STT+TTS\STT+TTS\MainForm.cs:line 74 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at STT_TTS.Program.Main() in C:\Documents and Settings\Administrator\Desktop\STT+TTS Application\STT+TTS\STT+TTS\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() InnerException: System.Runtime.InteropServices.COMException Message="Exception from HRESULT: 0x8004503A" Source="Microsoft.Speech" ErrorCode=-2147200966 StackTrace: at Microsoft.Speech.Internal.SapiInterop.ISpRecoGrammar2.LoadCmdFromMemory2(IntPtr pGrammar, SPLOADOPTIONS Options, String pszSharingUri, String pszBaseUri) at Microsoft.Speech.Internal.SapiInterop.SapiGrammar53.LoadCmdFromMemory2(IntPtr grammar, SPLOADOPTIONS options, String sharingUri, String baseUri) at Microsoft.Speech.Recognition.MemoryGrammarContent.Load(SapiGrammar sapiGrammar, Boolean enabled, Single weight, Int32 priority) InnerException: ///////////////////////////////////////////////////////////////////////////////////
|
Pages: 1 Prev: MC9090 Install Next: Windows Image Acquisition library problems |