一个基于WinCE平台的语音朗读例子,利用微软speechAPI5.0

该博客提供了一个基于Windows CE平台的简单示例,利用微软的speechAPI5.0进行语音朗读。通过代码展示了如何创建并实例化语音对象,以及如何使用语音对象播放文本。
摘要由CSDN通过智能技术生成

#include "stdafx.h"
#include "atlbase.h"
#include <sphelper.h>

int _tmain(int argc, TCHAR* argv[])
{
    HRESULT hr=S_FALSE;
    WCHAR wcBuff[MAX_PATH];
    int i;

    if( argc < 2 )
    {
        //--- Give out a helpstring
        wcscpy( wcBuff, L"This is a simple sample sentence." );
    }
    else
    {
  for( i = 1, wcBuff[0] = 0; i < argc; ++i )
  {
   wcscat( wcscat( wcBuff, argv[i] ), L" " );
  }
    }

    if( SUCCEEDED( hr = CoInitializeEx( NULL, COINIT_MULTITHREADED ) ) )
    {
        //--- Create the voice
        CComPtr<ISpVoice> cpVoice;
        hr = cpVoice.CoCreateInstance(CLSID_SpVoice);
        if( SUCCEEDED( hr ) )
        {
            hr = cpVoice->Speak(wcBuff, 0, NULL);
//            if( SUCCEEDED( hr ) )
//            {
//                hr = cpVoice->WaitUntilDone(INFINITE);
//            }
        }
        if (cpVoice)
            cpVoice.Release();

        CoUninitialize();
    }

 if (FAILED(hr)) return 1;
 return 0;
}

 

 

 

 

//--- Includes --------------------------------------------------------------

#include <windows.h>
#include <stdio.h>
#include <atlbase.h>
#include <shellapi.h>
#include <sapi.h>

//--- Const Defines----------------------------------------------------------

const static WCHAR g_szMarkupDemo[] =
    L"<VOICE OPTIONAL=/"Female/">Tags can be used to change attributes such as/n"
    L"    <VOICE OPTIONAL=/"Gender=Male;Volume=Loud/">the voice font that is used,</VOICE>/n"
    L"    the <VOLUME LEVEL=/"65/&

评论 31
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

尹成

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值