一个基于WinCE平台的语音识别例子,利用微软speechAPI5 0

这是一个使用微软SpeechAPI5.0在WinCE平台上实现语音识别的例子,通过C++代码展示了如何创建语音识别上下文、加载语法和监听语音输入,以实现语音交互功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

               

#include <windows.h>
#include <sapi.h>
#include <stdio.h>
#include <string.h>
#include <atlbase.h>
#include "sphelper.h"

 

inline HRESULT BlockForResult(ISpRecoContext * pRecoCtxt, ISpRecoResult ** ppResult)
{

//创建语音识别
    HRESULT hr = S_OK;
 CSpEvent event;

    while (SUCCEEDED(hr) &&
           SUCCEEDED(hr = event.GetFrom(pRecoCtxt)) &&
           hr == S_FALSE)
    {
        hr = pRecoCtxt->WaitForNotifyEvent(INFINITE);
    }

    *ppResult = event.RecoResult();
    if (*ppResult)
    {
        (*ppResult)->AddRef();


    }

    return hr;
}

const WCHAR * StopWord()
{
    const WCHAR * pchStop;
   
    LANGID LangId = ::SpGetUserDefaultUILanguage();

    switch (LangId)
    {
        case MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT):
            pchStop = L"/x7d42/x4e86///x30b7/x30e5/x30fc/x30ea/x30e7/x30fc//x3057/x3085/x3046/x308a/x3087/x3046";;
            break;

        default:
            pchStop = L"Stop";
            break;
    }

    return pchStop;
}
           
int _tmain(int argc, TCHAR* argv[])
{
    HRESULT hr = E_FAIL;
    bool fUseTTS = true;            // turn TTS play back on or off
    bool fReplay = true;            // turn Audio replay on or off

    TCHAR   szFileName[256];

    // Process optional arguments
    if (argc > 1)
    {
        int i;

        for (i = 1; i < argc; i++)
        {
            if (_tcsicmp(argv[i], _T("-noTTS")) == 0)
            {
                fUseTTS = false;
                continue;
            }
            if (_tcsicmp(argv[i], _T("-noReplay")) == 0)
            {
                fReplay = false;
           &nbs

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值