当“event.GetFrom(m_cpVoice)==S_OK”时调用函数(因此,当事件发生时)[SAPI 5.1 和 C++]
我正在做一个带有 3D 模型的项目,这说明了这一点。 因此,我正在使用 SAPI 5.1,并且我想在存在 Viseme 事件时异步调用函数(以便播放相关的动画)。
我怎样才能做到呢?
非常感谢。
注意:我使用: hRes = m_cpVoice->Speak(L"All I想要的是解决这个问题", SPF_ASYNC , NULL); 我知道 CspEvent, event.eEventId 。我想要的只是当 Sapi 事件发生时如何调用函数
I'm doing a project with a 3D model, that speaks.
So, I'm using SAPI 5.1, and I want to call a function asynchronously when there's a Viseme event (in order to play the animation related to).
How could I do it?
Thank you very much.
Note: I use : hRes = m_cpVoice->Speak(L"All I want is to solve this problem", SPF_ASYNC , NULL);
And I know the CspEvent, event.eEventId . All I want is how to call a function when Sapi event happens
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要调用 m_cpVoice->SetInterest (SPFEI(SPEI_VISEME), SPFEI(SPEI_VISEME));这将告诉 SAPI 在 VISEME 事件触发时发送事件。
其次,您需要通过调用 m_cpVoice->SetNotifyCallbackInterface,带有您的回调。 (它必须实现 ISpNotifyCallback,其中是您的对象将实现的虚拟 C++ 接口。)
您可以查看 SAPI 事件文档 了解更多详细信息。
ISpNotifyCallback 的示例实现如下所示:
TTSHandler.h:
TTSHandler.cpp:
First, you need to call m_cpVoice->SetInterest(SPFEI(SPEI_VISEME), SPFEI(SPEI_VISEME)); that will tell SAPI to send an event when a VISEME event fires.
Second, you need to set up an event handler by calling m_cpVoice->SetNotifyCallbackInterface, with your callback. (It must implement ISpNotifyCallback, which is a virtual C++ interface that your object would implement.)
You can look at the SAPI events documentation for more details.
A sample implementation of ISpNotifyCallback would look like this:
TTSHandler.h:
TTSHandler.cpp: