无法在语音识别处理程序中启用计时器 [英] Can't enable a Timer in a Speech Recognized handler

查看:87
本文介绍了无法在语音识别处理程序中启用计时器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请注意,虽然这涉及到SAPI,但更多的是关于计时器的问题

和事件处理程序。


我写了一个语音识别处理程序(SAPI) ,并在其中加入一些代码以启用

a计时器。它不会这样做。如果我把这个相同的代码带到这个活动之外

处理程序,它就可以了。


这是正常的吗?

Note that although this involves SAPI, it is more a question about Timers
and event handlers.

I wrote a Speech Recognize handler (SAPI), and put some code in it to enable
a Timer. It would not do it. If I bring this same code outside this event
handler, it works just fine.

Is this normal?

推荐答案

>请注意,虽然这涉及SAPI,但更多的是关于计时器的问题
>Note that although this involves SAPI, it is more a question about Timers

>和事件处理程序。

我写了一个语音识别处理程序(SAPI),并在其中加入一些代码来启用计时器。它不会这样做。如果我将此相同的代码带到此事件处理程序之外,它就可以正常工作。
>and event handlers.

I wrote a Speech Recognize handler (SAPI), and put some code in it to enable
a Timer. It would not do it. If I bring this same code outside this event
handler, it works just fine.



您使用的代码是什么?


您需要告诉我们更多信息!


Dave

And the code you''ve used it what?

You need to tell us a bit more!

Dave




" Peter Oliphant" < pe ******** @ hotmail.comwrote in message

news:6F ********************** ************ @ microsof t.com ...

"Peter Oliphant" <pe********@hotmail.comwrote in message
news:6F**********************************@microsof t.com...

请注意,虽然这涉及SAPI,但更多的是关于计时器的问题

和事件处理程序。


我写了一个语音识别处理程序(SAPI),并在其中加入了一些代码

enable一个计时器。它不会这样做。如果我把这个相同的代码带到这个

事件处理程序之外,它就可以正常工作。


这是正常的吗?
Note that although this involves SAPI, it is more a question about Timers
and event handlers.

I wrote a Speech Recognize handler (SAPI), and put some code in it to
enable a Timer. It would not do it. If I bring this same code outside this
event handler, it works just fine.

Is this normal?



哪个定时器? .NET至少有三个不同的类名为Timer。

Which "Timer"? .NET has at least three different classes named Timer.


我希望这个新闻组能够至少附加一个带有

代码的文本文件。我的代码来证明这种情况太长了,这个新闻组

如果行太长,往往会以错误的方式重新格式化文本。


但是,我会试着解释一下。假设在下面的''计时器''

设置了一个间隔和事件处理程序:


System :: Windows :: Forms :: Timer ^ timer = gcnew Timer();


void Handler(Object ^,SpeechRecognizedEventArgs ^ e)

{

timer-> ;启用; //问题!

}


也就是说,如果我尝试在''识别语音'处理程序中启动计时器

它没有启用计时器。我相信它也锁定了计时器,然后

on(计时器不再响应任何命令)。如果这个代码在处理程序之外放置了

,它就可以很好地启动计时器。


仅供参考,使用MS VS VC ++ 2008 Express(Beta 2)

Vista计算机上的.NET Framework 3.5。 (SAPI 5.3 ala Vista)。托管(/ cli)代码生成。


我有一个解决方法,但它并不精彩。我创建了一个外部主人

计时器,用于轮询是否应该通过他们的

个别标志打开其他计时器,然后将计时器的标志设置为相反,在

以上的处理程序中启动。当然缺点是这增加了一个不可预测的额外延迟(因为它可以通过在主计时器的任何一点设置

计时器标志来提出请求)间隔),虽然它是人类条款的短缺。


我试着把它移到演讲的识别完成处理程序中

识别器思考或许是广泛的识别处理导致了这个问题。但是那个处理程序也不会启动计时器。


希望对信息部门有所帮助。这可能是一个问题或

功能。如果出现问题,它可能是SAPI或VC ++的一部分。它可能是我的代码中的一个错误,但我发现这种情况有两种不同的方式(或者不会发生,如果

你会),所以这不太可能。我想知道从一个(任何?)事件处理程序中启动一个系统计时器是否只是在一般情况下是不允许的。例如,计时器

处理程序可以启动另一个计时器吗?


不要犹豫,问你是否想要一些具体的问题...


谢谢!


[== Peter ==]

" David Lowndes" < Da **** @ example.invalidwrote in message

news:l9 ************************** ****** @ 4ax.com ...
I wish this newsgroup had an ability to at least attach a text file with
code. My code to demonstrate this situation is too long, and this newsgroup
tends to reformat the text in a bad way if the line is too long.

But, I''ll try to explain it a bit more. Assume in the following that ''timer''
is set up with an interval and event handler:

System::Windows::Forms::Timer^ timer = gcnew Timer() ;

void Handler( Object^, SpeechRecognizedEventArgs^ e )
{
timer->Enable ; // problem!
}

That is, if I try to launch a timer inside the ''recognized speech'' handler
it doesn''t enable the timer. I believe it also locks out the timer from then
on (timer no longer responds to any commands). If this code is placed
outside of the handler, it launches the timer just fine.

FYI, using MS VS VC++ 2008 Express (Beta 2) with .NET Framework 3.5 on a
Vista machine. (SAPI 5.3 ala Vista). Managed (/cli) code generation.

I have a workaround, but it''s not wonderful. I create an external ''master''
timer that polls whether other timers should be turned on via their
individual flags, and then set the flag of the timer to be launched in the
above handler instead. The disadvantage of course is that this adds an
unpredictable additonal lag (since it can make the request by setting the
timer flag at any point in the master timer''s interval), although it is
short by human terms.

I tried moving this to the Recognition Completed handler of the speech
recognizer thinking perhaps it was the extensive recognition processing that
caused the problem. But that handler won''t launch a timer either.

Hope that helps in the info department. This could be a problem or a
feature. If a problem, it could be part of SAPI or VC++.It could be a bug in
my code, but I''ve seen this happen two different ways (or NOT happeneing, if
you will), so this is not likely. I''m wondering if it is just disallowed in
general to launch a System Timer from an (any?) event handler. Can a Timer
handler launch another Timer, for instance?

Don''t hesitate to ask if you want some specific questions asked...

Thanks!

[==Peter==]
"David Lowndes" <Da****@example.invalidwrote in message
news:l9********************************@4ax.com...

请注意,虽然这涉及SAPI,但它更像是一个问题定时器
和事件处理程序。

我写了一个语音识别处理程序(SAPI),并在其中加入了一些代码来启用定时器。它不会这样做。如果我将此相同的代码带到此事件处理程序之外,它就可以正常工作。
Note that although this involves SAPI, it is more a question about Timers
and event handlers.

I wrote a Speech Recognize handler (SAPI), and put some code in it to
enable
a Timer. It would not do it. If I bring this same code outside this event
handler, it works just fine.



您使用的代码是什么?


您需要告诉我们更多信息!


戴夫


And the code you''ve used it what?

You need to tell us a bit more!

Dave



这篇关于无法在语音识别处理程序中启用计时器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆