go download Microsoft Speech SDK, there is sample code in it:
http://www.microsoft.com/speech/sapi51/SpeechSDK/sdk51.asp

解决方案 »

  1.   

    楼上哥哥,我是教育网的用户,上不了鬼佬的网站,sorry
    谁可以提供实际一点的信息???
      

  2.   

    From Speech SDK:Microsoft Speech SDK SAPI 5.1 
    --------------------------------------Text-to-Speech Tutorial
    This tutorial covers a very basic text-to-speech (TTS) example. The console application is one of the simplest demonstrations of speech. It is the "Hello World" equivalent for TTS. An equivalent sample for a Windows application using a graphical interface (and event pump) is available in Using Events with TTS.The sample builds up from the simplest (though nonfunctional) COM framework to speaking a sentence. Steps are provided for each new function. The sample even goes one step beyond demonstrating the use XML tags to modify speech. The Complete Sample Application is at the bottom of the page.Step 1: Setting Up The Project
    Step 2: Initialize COM
    Step 3: Setting Up Voices
    Step 4: Speak!
    Step 5: Modifying SpeechStep 1: Setting up the project
    While it is possible to write an application from scratch, it is easier to start from an existing project. In this case, use Visual Studio's application wizard to create a Win32 console application. Choose "Hello, world" as the sample when asked during the wizard set up. After generating it, open the STDAfx.h file and paste the following code after "#include <stdio.h>" but before the "#endif" statement. This sets up the additional dependencies SAPI requires.#define _ATL_APARTMENT_THREADED#include <atlbase.h>
    //You may derive a class from CComModule and use it if you want to override something, 
    //but do not change the name of _Module
    extern CComModule _Module;
    #include <atlcom.h>Code Listing 1Next add the paths to SAPI.h and SAPI.lib files. The paths shown are for a standard SAPI SDK install. If the compiler is unable to locate either file, or if a nonstandard install was performed, use the new path to the files. Change the project settings to reflect the paths. Using the Project->Settings. menu item, set the SAPI.h path. Click the C/C++ tab and select Preprocessor from the Category drop-down list. Enter the following in the "Additional include directories": C:\Program Files\Microsoft Speech SDK 5.1\Include.To set the SAPI.lib path:Select the Link tab from the Same Settings dialog box. 
    Choose Input from the Category drop-down list. 
    Add the following path to the "Additional library path": 
    C:\Program Files\Microsoft Speech SDK 5.1\Lib\i386. 
    Also add "sapi.lib" to the "Object/library modules" line. Be sure that the name is separated by a space. 
    Step 2: Initialize COM
    SAPI is a COM-based application, and COM must be initialized both before use and during the time SAPI is active. In most cases, this is for the lifetime of the host application. The following code (from Listing 2) initializes COM. Of course, the application does not do anything beyond initialization, but it does ensure that COM is successfully started.#include <stdafx.h>
    #include <sapi.h>int main(int argc, char* argv[])
    {
        if (FAILED(::CoInitialize(NULL)))
            return FALSE;    ::CoUninitialize();
        return TRUE;
    }Code Listing 2Step 3: Setting up voices
    Once COM is running, the next step is to create the voice. A voice is simply a COM object. Additionally, SAPI uses intelligent defaults. During initialization of the object, SAPI assigns most values automatically so that the object may be used immediately afterward. This represents an important improvement from earlier versions. The defaults are retrieved from Speech properties in Control Panel and include such information as the voice (if more than one is available on your system), and the language (English, Japanese, etc.). While some defaults are obvious, others are not (speaking rate, pitch, etc.). Nevertheless, all defaults may be changed either programmatically or in Speech properties in Control Panel.Setting the pVoice pointer to NULL is not required but is useful for checking errors; this ensures an invalid pointer is not reused, or as a reminder that the pointer has already been allocated or deallocated#include <stdafx.h>
    #include <sapi.h>int main(int argc, char* argv[])
    {
        ISpVoice * pVoice = NULL;    if (FAILED(::CoInitialize(NULL)))
            return FALSE;    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
        if( SUCCEEDED( hr ) )
        {
            pVoice->Release();
            pVoice = NULL;
        }    ::CoUninitialize();
        return TRUE;
    }Code Listing 3. Bold text represents new code for this example.Step 4: Speak!
    The actual speaking of the phrase is an equally simple task: one line calling the Speak function. When the instance of the voice is no longer needed, you can release the object.#include <stdafx.h>
    #include <sapi.h>int main(int argc, char* argv[])
    {
        ISpVoice * pVoice = NULL;    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"Hello world", 0, NULL);
            pVoice->Release();
            pVoice = NULL;
        }    ::CoUninitialize();
        return TRUE;
    }Code Listing 4. Bold text represents new code for this example.Step 5: Modifying Speech
    Voices may be modified using a variety of methods. The most direct way is to apply XML commands directly to the stream. The commands are outlined in XML Schema. In this case, a relative rating of 10 will lower the pitch of the voice.#include <stdafx.h>
    #include <sapi.h>int main(int argc, char* argv[])
    {
        ISpVoice * pVoice = NULL;    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"Hello world", 0, NULL);        // Change pitch
            hr = pVoice->Speak(L"This sounds normal <pitch middle = '-10'/> but the pitch drops half way through", SPF_IS_XML, NULL );
            pVoice->Release();
            pVoice = NULL;
        }
        ::CoUninitialize();
        return TRUE;
    }
    Code Listing 5. Bold text represents new code for this example. This is the complete code sample.
      

  3.   

    朗读,m_cpVoice->Speak
    人物,m_cpVoice->SetVoice
    音量,m_cpVoice->SetVolume
    速度,m_cpVoice->SetRateTTS5里没有音调的说法。
      

  4.   

    就这样子呀。
    我不想要那个tts sdk开发环境
    我想通过直接引用tts那个vautotext.tlb库
    再mfc环境下快快乐乐完成语音功能
    大家继续发音,分我一定会给!!
      

  5.   

    do rei mi fa so la xi
      

  6.   

    无为兄:
    有没有现成的例子(注意不要那个tts sdk下面的)?
    如果有可以发送一个给我吗?
    300分都可以送给你作为你劳动的一点补偿[email protected]
      

  7.   

    Dim sv As SpeechLib.SpVoice
    Set sv = New SpVoice
    sv.Speak "Bad World"
    set sv = Nothing
      

  8.   

    How to get the TTS!
    It seems not in My computer ? 
      

  9.   

    我再试试up,最后一次up,否则我就把分数……白扔了:)
      

  10.   

    微软的TTs开发包里面有例子,我仿照着做了一个,没问题呀。
      

  11.   

    把你的E-mail写下来,我把这个类发给你。
      

  12.   

    我已经发到你的邮箱了,要使用这个类,首先要下载微软的SPeech SDK5.0的开发包,然后需要在程序中将sapi.lib中加入,(在你安装目录中);还要在Tools的Option目录里的Directories中将它Include进来,这样才可以直接使用它的函数。
      

  13.   

    牛人来了!!!!!!!!1.project ->addproject->compounents and controls->gallary->texttospeech Class加入后,包含文件
    在你的地方输入: int start=0 ,end=0; pActiveView->GetEditCtrl().GetSel(start,end); pActiveView->GetEditCtrl().GetWindowText (strSay); strSay=strSay.Mid(start,end-start);
      

  14.   

    m_tts.Speak((LPCSTR)strSay);
    速度: m_tts.SetSpeed(120);//120 words per minute
    人物:     m_tts.Age(10);
      
    函数
    // Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++// NOTE: Do not modify the contents of this file.  If this class is regenerated by
    //  Microsoft Visual C++, your modifications will be overwritten.
    #include "stdafx.h"
    #include "texttospeech.h"/////////////////////////////////////////////////////////////////////////////
    // CTextToSpeechIMPLEMENT_DYNCREATE(CTextToSpeech, CWnd)/////////////////////////////////////////////////////////////////////////////
    // CTextToSpeech properties/////////////////////////////////////////////////////////////////////////////
    // CTextToSpeech operationslong CTextToSpeech::GetInitialized()
    {
    long result;
    InvokeHelper(0x1, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetInitialized(long nNewValue)
    {
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }void CTextToSpeech::Speak(LPCTSTR Text)
    {
    static BYTE parms[] =
    VTS_BSTR;
    InvokeHelper(0x2, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
     Text);
    }void CTextToSpeech::StopSpeaking()
    {
    InvokeHelper(0x3, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
    }void CTextToSpeech::FastForward()
    {
    InvokeHelper(0x4, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
    }void CTextToSpeech::Pause()
    {
    InvokeHelper(0x5, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
    }void CTextToSpeech::Resume()
    {
    InvokeHelper(0x6, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
    }void CTextToSpeech::Rewind()
    {
    InvokeHelper(0x7, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
    }long CTextToSpeech::GetDevice()
    {
    long result;
    InvokeHelper(0x8, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetDevice(long nNewValue)
    {
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x8, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }long CTextToSpeech::GetEnabled()
    {
    long result;
    InvokeHelper(0x9, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetEnabled(long nNewValue)
    {
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }long CTextToSpeech::GetIsSpeaking()
    {
    long result;
    InvokeHelper(0xa, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
    return result;
    }long CTextToSpeech::GetSpeed()
    {
    long result;
    InvokeHelper(0xb, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetSpeed(long nNewValue)
    {
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0xb, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }CString CTextToSpeech::GetTTSMode()
    {
    CString result;
    InvokeHelper(0xc, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetTTSMode(LPCTSTR lpszNewValue)
    {
    static BYTE parms[] =
    VTS_BSTR;
    InvokeHelper(0xc, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     lpszNewValue);
    }void CTextToSpeech::AboutDlg(long hWnd, LPCTSTR title)
    {
    static BYTE parms[] =
    VTS_I4 VTS_BSTR;
    InvokeHelper(0xd, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
     hWnd, title);
    }void CTextToSpeech::GeneralDlg(long hWnd, LPCTSTR title)
    {
    static BYTE parms[] =
    VTS_I4 VTS_BSTR;
    InvokeHelper(0xe, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
     hWnd, title);
    }void CTextToSpeech::LexiconDlg(long hWnd, LPCTSTR title)
    {
    static BYTE parms[] =
    VTS_I4 VTS_BSTR;
    InvokeHelper(0xf, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
     hWnd, title);
    }void CTextToSpeech::TranslateDlg(long hWnd, LPCTSTR title)
    {
    static BYTE parms[] =
    VTS_I4 VTS_BSTR;
    InvokeHelper(0x10, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
     hWnd, title);
    }long CTextToSpeech::GetFindEngine(LPCTSTR EngineId, LPCTSTR MfgName, LPCTSTR ProductName, LPCTSTR ModeID, LPCTSTR ModeName, long LanguageID, LPCTSTR dialect, LPCTSTR Speaker, LPCTSTR Style, long Gender, long Age, long Features, long Interfaces, 
    long EngineFeatures, long RankEngineID, long RankMfgName, long RankProductName, long RankModeID, long RankModeName, long RankLanguage, long RankDialect, long RankSpeaker, long RankStyle, long RankGender, long RankAge, long RankFeatures, 
    long RankInterfaces, long RankEngineFeatures)
    {
    long result;
    static BYTE parms[] =
    VTS_BSTR VTS_BSTR VTS_BSTR VTS_BSTR VTS_BSTR VTS_I4 VTS_BSTR VTS_BSTR VTS_BSTR VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4;
    InvokeHelper(0x11, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, parms,
    EngineId, MfgName, ProductName, ModeID, ModeName, LanguageID, dialect, Speaker, Style, Gender, Age, Features, Interfaces, EngineFeatures, RankEngineID, RankMfgName, RankProductName, RankModeID, RankModeName, RankLanguage, RankDialect, 
    RankSpeaker, RankStyle, RankGender, RankAge, RankFeatures, RankInterfaces, RankEngineFeatures);
    return result;
    }long CTextToSpeech::GetCountEngines()
    {
    long result;
    InvokeHelper(0x12, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
    return result;
    }CString CTextToSpeech::ModeName(long index)
    {
    CString result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x13, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms,
    index);
    return result;
    }CString CTextToSpeech::MfgName(long index)
    {
    CString result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x14, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms,
    index);
    return result;
    }CString CTextToSpeech::ProductName(long index)
    {
    CString result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x15, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms,
    index);
    return result;
    }CString CTextToSpeech::ModeID(long index)
    {
    CString result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x16, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms,
    index);
    return result;
    }CString CTextToSpeech::Speaker(long index)
    {
    CString result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x17, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms,
    index);
    return result;
    }CString CTextToSpeech::Style(long index)
    {
    CString result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x18, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms,
    index);
    return result;
    }long CTextToSpeech::Gender(long index)
    {
    long result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x19, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
    index);
    return result;
    }long CTextToSpeech::Age(long index)
    {
    long result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x1a, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
    index);
    return result;
    }long CTextToSpeech::Features(long index)
    {
    long result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x1b, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
    index);
    return result;
    }long CTextToSpeech::Interfaces(long index)
    {
    long result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x1c, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
    index);
    return result;
    }long CTextToSpeech::EngineFeatures(long index)
    {
    long result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x1d, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
    index);
    return result;
    }long CTextToSpeech::LanguageID(long index)
    {
    long result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x1e, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
    index);
    return result;
    }CString CTextToSpeech::dialect(long index)
    {
    CString result;
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x1f, DISPATCH_METHOD, VT_BSTR, (void*)&result, parms,
    index);
    return result;
    }short CTextToSpeech::GetMouthHeight()
    {
    short result;
    InvokeHelper(0x31, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetMouthHeight(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x31, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }short CTextToSpeech::GetMouthWidth()
    {
    short result;
    InvokeHelper(0x32, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetMouthWidth(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x32, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }short CTextToSpeech::GetMouthUpturn()
    {
    short result;
    InvokeHelper(0x33, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetMouthUpturn(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x33, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }short CTextToSpeech::GetJawOpen()
    {
    short result;
    InvokeHelper(0x34, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetJawOpen(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x34, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }short CTextToSpeech::GetTeethUpperVisible()
    {
    short result;
    InvokeHelper(0x35, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetTeethUpperVisible(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x35, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }short CTextToSpeech::GetTeethLowerVisible()
    {
    short result;
    InvokeHelper(0x36, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetTeethLowerVisible(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x36, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }short CTextToSpeech::GetTonguePosn()
    {
    short result;
    InvokeHelper(0x37, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetTonguePosn(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x37, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }short CTextToSpeech::GetLipTension()
    {
    short result;
    InvokeHelper(0x38, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetLipTension(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x38, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }long CTextToSpeech::GetLastError()
    {
    long result;
    InvokeHelper(0x3b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetLastError(long nNewValue)
    {
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x3b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }short CTextToSpeech::GetSuppressExceptions()
    {
    short result;
    InvokeHelper(0x3c, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetSuppressExceptions(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x3c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }void CTextToSpeech::Select(long index)
    {
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x3d, DISPATCH_METHOD, VT_EMPTY, NULL, parms,
     index);
    }short CTextToSpeech::GetLipType()
    {
    short result;
    InvokeHelper(0x3e, DISPATCH_PROPERTYGET, VT_I2, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetLipType(short nNewValue)
    {
    static BYTE parms[] =
    VTS_I2;
    InvokeHelper(0x3e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }long CTextToSpeech::GetCurrentMode()
    {
    long result;
    InvokeHelper(0x3f, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
    return result;
    }void CTextToSpeech::SetCurrentMode(long nNewValue)
    {
    static BYTE parms[] =
    VTS_I4;
    InvokeHelper(0x3f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
     nNewValue);
    }long CTextToSpeech::GetHWnd()
    {
    long result;
    InvokeHelper(0x40, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
    return result;
    }long CTextToSpeech::Find(LPCTSTR RankList)
    {
    long result;
    static BYTE parms[] =
    VTS_BSTR;
    InvokeHelper(0x41, DISPATCH_METHOD, VT_I4, (void*)&result, parms,
    RankList);
    return result;
    }