当前位置: 首页>>代码示例>>C++>>正文


C++ ISpVoice::DisplayUI方法代码示例

本文整理汇总了C++中ISpVoice::DisplayUI方法的典型用法代码示例。如果您正苦于以下问题:C++ ISpVoice::DisplayUI方法的具体用法?C++ ISpVoice::DisplayUI怎么用?C++ ISpVoice::DisplayUI使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISpVoice的用法示例。


在下文中一共展示了ISpVoice::DisplayUI方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char **argv)
{
    ISpVoice *pVoice = NULL;
    WCHAR line_buffer[LINE_LENGTH];
    bool exitflag = FALSE;
    int counter = 0;

    if (FAILED(::CoInitialize(NULL)))
    {
        printf("ERROR: Couldn't initialise COM.\n");
        return FALSE;
    }

    HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
    if( SUCCEEDED( hr ) )
    {
        // For some reason, if you don't do this, speech cuts out
        // (only on first announcement)...
        pVoice->Speak(L" ", SPF_IS_NOT_XML, NULL);

        // Main loop...
        while( ! exitflag )
        {
            for(counter = 0; counter < LINE_LENGTH; counter++ )
            {
                // Fill up the buffer...
                line_buffer[counter] = getwchar();

                // Check for exit condition...
                if( line_buffer[counter] == WEOF )
                {
                    line_buffer[counter] = 0;
                    exitflag = TRUE;
                    break;
                }

                // Break at end of line...
                if( line_buffer[counter] == L'\n' )
                {
                    line_buffer[counter] = 0;
                    break;
                }
            }

            counter = 0;

            // Should the synth's UI be displayed?
            if ( line_buffer == L"DisplayUI" )
            {
                int supported = 0;
                hr = pVoice->IsUISupported(SPDUI_EngineProperties, NULL, NULL, &supported);
                if( SUCCEEDED( hr ) && supported )
                {
                    hr = pVoice->DisplayUI(NULL, NULL, SPDUI_EngineProperties, NULL, NULL);
                    if( ! SUCCEEDED( hr ) )
                    {
                        pVoice->Speak(L"There was an error displaying the properties window.\n", SPF_IS_NOT_XML|SPF_ASYNC|SPF_PURGEBEFORESPEAK, NULL);
                    }
                }
                else
                {
                    pVoice->Speak(L"Your current voice doesn't support a properties window.\n", SPF_IS_NOT_XML|SPF_ASYNC|SPF_PURGEBEFORESPEAK, NULL);
                }
            }

            // Was the message high-priority?
            if( line_buffer[0] == L'!' )
            {
                line_buffer[0] = L' ';
                pVoice->Speak(line_buffer, SPF_IS_NOT_XML|SPF_ASYNC|SPF_PURGEBEFORESPEAK, NULL);
            }
            else
            {
                pVoice->Speak(line_buffer, SPF_IS_NOT_XML|SPF_ASYNC, NULL);
            }
        }

        // Allow the user to hear the rest of the speech buffer...
        pVoice->Speak(L" ", SPF_IS_NOT_XML, NULL);

        pVoice->Release();
        pVoice = NULL;
    }
    else
    {
        printf("ERROR: Couldn't initialise SAPI 5.1.\n");
    }

    ::CoUninitialize();
    return TRUE;
}
开发者ID:philogus,项目名称:agrip,代码行数:91,代码来源:ag_say.cpp


注:本文中的ISpVoice::DisplayUI方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。