在 SAPI 中说出进度事件
Speak Progress Event in SAPI
我正在尝试使用Microsoft SAPI编写文本到语音转换程序。为此,我有以下代码:
ISpVoice * pVoice = NULL;
int main(int argc, char* argv[])
{
if (FAILED(::CoInitialize(NULL)))
return FALSE;
HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
if (SUCCEEDED(hr))
{
hr = pVoice->Speak(L"Anyone who reads Old and Middle English literary texts will be familiar with the mid-brown volumes of the EETS, with the symbol of Alfred's jewel embossed on the front cover. Most of the works attributed to King Alfred or to Aelfric, along with some of those by bishop Wulfstan and much anonymous prose and verse from the pre-Conquest period, are to be found within the Society's three series; all of the surviving medieval drama, most of the Middle English romances, much religious and secular prose and verse including the English works of John Gower, Thomas Hoccleve and most of Caxton's prints all find their place in the publications. Without EETS editions, study of medieval English texts would hardly be possible.", SPF_IS_XML, NULL);
pVoice->Release();
pVoice = NULL;
}
::CoUninitialize();
return TRUE;
}
我想将朗读进度打印到屏幕上,在说出每个单词时打印出来。与System.Speech.Synthesis
类似:
synth.SpeakProgress += new EventHandler<SpeakProgressEventArgs>(synth_SpeakProgress);
有关更多详细信息:使用语音合成事件
那么,如何使用 SAP 做到这一点呢?
ISpVoice
继承自ISpEventSource
,而又继承自ISpNotifySource
。
使用ISpEventSource::SetInterest()
方法注册所需事件,例如SPEI_WORD_BOUNDARY
:
一个词开始合成。标记语言 (XML) 标记计入边界和偏移量。
wParam
是正在合成的当前输入流中单词的字符长度。lParam
是正在合成的单词的当前文本输入流中的字符位置。
使用各种ISpNotifySource::SetNotify...()
方法指定希望如何从 SAP 接收事件:
-
SetNotifySink()
通过您提供的ISpNotifySink
接口接收事件。 -
SetNotifyWindowMessage()
在您选择的HWND
接收事件。 -
SetNotifyCallbackFunction()
在您提供的回调函数中接收事件。 -
SetNotifyCallbackInterface()
通过您提供的ISpNotifyCallback
接口接收事件。 -
SetNotifyWin32Event
创建一个事件对象,该对象在新事件到达时发出信号。若要等待事件,请使用ISpNotifySource::WaitForNotifyEvent()
或具有标准 Win32 等待函数(如WaitForSingleObject()
)的ISpNotifySource::GetNotifyEventHandle
。
当您收到新事件的通知时,如果需要,请使用ISpEventSource::GetEvents()
获取详细的事件信息。
- Android NDK传感器向事件队列报告奇怪的间隔
- 从文本文件中读取时钟时间和事件时间并进行处理
- WMI检测进程创建事件-c++
- EvtExportLogneneneba API正在将远程计算机的事件日志保存到远程PC本身.如何将其保存到主机
- 处理闪烁窗口事件
- C++Builder中的OnClick事件签名存在问题
- 跟踪滚动条上的鼠标事件
- 什么是事件表 (wxWidgets)?
- 如何在 MFCaptureEngine 中获取"Camera removed"事件
- 给定顺序中的事件处理
- 当服务中的事件被触发时,如何将响应从服务发送回客户端?
- 在 C++/CLI 中将 .NET 事件从一个 DLL 引发到另一个 DLL
- 如何创建事件驱动的 SDL2 应用程序
- Windows 进程间同步类似事件?
- 如何从C++端挂接到 QML 项的 onClick 事件
- 如何通过多类"Union variable" (sfml) 使用轮询事件
- 如何在Qt 4.8中阻止/忽略/丢弃早于特定超时的用户输入事件
- C++ 信号和插槽不工作:插槽不响应事件
- 在 SAPI 中说出进度事件
- C++ Microsoft SAPI:异步使用事件和泵消息进行对话