我有一段代码,是用XML标签设的,不知该怎么设。hr = pVoice->Speak(<VOICE REQUIRED="Microsoft Simplified Chinese"/>m_Text.AllocSysString(), SPF_IS_XML, NULL);直接改这句还是在别处定义,求解释

解决方案 »

  1.   

    或者直接用ISpVoice::SetVoice函数怎么定义
      

  2.   

    HRESULT                             hr = S_OK;
    CComPtr<ISpObjectToken>             cpVoiceToken;
    CComPtr<IEnumSpObjectTokens>        cpEnum;
    CComPtr<ISpVoice>                   cpVoice;
    ULONG                               ulCount = 0;
    // Create the SAPI voice
    if(SUCCEEDED(hr))
        hr = cpVoice.CoCreateInstance( CLSID_SpVoice ); 
    //Enumerate the available voices 
    if(SUCCEEDED(hr))
        hr = SpEnumTokens(SPCAT_VOICES, NULL, NULL, &cpEnum);
    //Get the number of voices
    if(SUCCEEDED(hr))
        hr = cpEnum->GetCount(&ulCount);
    // Obtain a list of available voice tokens, set the voice to the token, and
    call Speak
    while (SUCCEEDED(hr) && ulCount -- )
    {
        cpVoiceToken.Release();
        if(SUCCEEDED(hr))
            hr = cpEnum->Next( 1, &cpVoiceToken, NULL );
        if(SUCCEEDED(hr))
            hr = cpVoice->SetVoice(cpVoiceToken);
        if(SUCCEEDED(hr))
            hr = cpVoice->Speak( L"How are you?", SPF_DEFAULT, NULL); 
    }