- UID
- 3260
- 精华
- 积分
- 648
- 威望
- 点
- 宅币
- 个
- 贡献
- 次
- 宅之契约
- 份
- 最后登录
- 1970-1-1
- 在线时间
- 小时
|
全局- #include Once "Afx/AfxSapi.bi"
- Const MSG_SAPI_EVENT = WM_USER + 1
- ' --> change me
- Dim Shared pSpVoice As Afx_ISpVoice Ptr
复制代码
初始
- pSpVoice = AfxNewCom("SAPI.SpVoice")
- If pSpVoice Then
- ' // 将感兴趣的对象设置为单词边界
- pSpVoice->SetInterest(SPFEI(SPEI_WORD_BOUNDARY), SPFEI(SPEI_WORD_BOUNDARY))
- ' // 设置将接收MSG_SAPI_EVENT消息的窗口的句柄
- pSpVoice->SetNotifyWindowMessage(hWndForm, MSG_SAPI_EVENT, 0, 0)
-
- Else
- AfxMsg "你的电脑里没有安装 微软TTS语音引擎"
- End If
复制代码
播放
- Dim cws As CWStr = FF_Control_GetText(HWND_FORM1_TEXT1)
- If pSpVoice Then
- pSpVoice->Speak(cws, SPF_ASYNC, Null)
- Else
- AfxMsg "你的电脑里没有安装 微软TTS语音引擎"
- End If
复制代码
源码下载:Basic语言编程群 78458582
|
|