Click here to Skip to main content
15,888,144 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
i have met a very funny problem:
I am using SpeechLib com in c# to speak sth, I have tried a simple test
either speak english or speak chinese by clicking a button, e.g. below simple code:
the funny thing is: for speaking english, it is fine, no problem. but when speaking Chinese, it works for the first click then it does not work for the second click, but if I click more, sometime it works, but most time, it does not speak.
Anyone knows the problem?
thanks!

C#
private void btn_read_Click(object sender, EventArgs e)
        {
            //play english
            SpVoice voice = new SpVoice();
            voice.Voice=voice.GetVoices(string.Empty, string.Empty).Item(0);
            voice.Speak("hello", SpeechVoiceSpeakFlags.SVSFlagsAsync);

            //play chinese
            SpVoice voice = new SpVoice();
            voice.Voice=voice.GetVoices(string.Empty, string.Empty).Item(1);
            voice.Speak("你好", SpeechVoiceSpeakFlags.SVSFlagsAsync);
        }
Posted
Updated 19-Jul-12 10:15am
v2
Comments
[no name] 19-Jul-12 19:36pm    
If you just use the Chinese voice does it do the same thing?
Seraph_summer 20-Jul-12 2:09am    
as I said, for Chinese, sometimes it works, sometimes, it does not work.
OriginalGriff 20-Jul-12 3:05am    
What Wes means is: If you remove the English part completely and only leave the Chinese, does it still have the same problem?
Seraph_summer 20-Jul-12 3:08am    
yes, the same problem.
Seraph_summer 20-Jul-12 4:06am    
can you please try also on your PC, the try is very simple,as you just need to add SpeechLib from com to your reference.
thanks!

1 solution

"can you please try also on your PC, the try is very simple,as you just need to add SpeechLib from com to your reference.
thanks!"


I immediately get an exception:

System.Runtime.InteropServices.COMException was unhandled
  Message=Exception from HRESULT: 0x80045039
  Source=AudioMaster
  ErrorCode=-2147200967
  StackTrace:
       at SpeechLib.ISpeechObjectTokens.Item(Int32 Index)
       at AudioMaster.Form1.button4_Click(Object sender, EventArgs e) in C:\Users\griff\Documents\My Projects\AudioMaster\AudioMaster\Form1.cs:line 191
       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(IntPtr 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 AudioMaster.Program.Main() in C:\Users\griff\Documents\My Projects\AudioMaster\AudioMaster\Program.cs:line 18
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly 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, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
Which presumably means that the engine is not initialized.

Have you checked if you are getting anything?
Single step show ok?
 
Share this answer
 
Comments
Seraph_summer 20-Jul-12 8:47am    
hi, thanks!
I played with by downloading speach SDK5.1 and so son, now the new problem becomes:

1) for english, still no problem
2) for Chinese, it does give error: the error is different from yours: Class not registered (exception from HRRESULT 0x80040154)
so far, I have not idea on how to fix it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900