【问题标题】:Is it possible to only load a dictation topic while using Shared Recogniser and not with Inproc reconizer in sapi?是否可以在使用共享识别器时只加载听写主题,而不是在 sapi 中使用 Inproc reconizer?
【发布时间】:2014-06-27 14:10:19
【问题描述】:

当我对以前注册的医学听写主题使用共享识别器时,听写语法加载没有错误,但是当我将识别器更改为 Inproc 识别器时,它无法加载听写主题。有没有办法在 proc 识别器中使用时加载听写主题?

我的加载语法代码看起来像

      CComPtr<ISpObjectToken>      cpObjectToken;
      CComPtr<ISpAudio>            cpAudio;
      CComPtr<ISpRecognizer> cpEngine;
      CComPtr<ISpRecoContext> cpRecoCtx;
      CComPtr<ISpRecoGrammar> cpGram;
      hr = cpEngine.CoCreateInstance(CLSID_SpInprocRecognizer);
      hr = SpGetDefaultTokenFromCategoryId(SPCAT_AUDIOIN, &cpObjectToken);
      hr = cpEngine->SetInput(cpObjectToken, TRUE);
      hr = SpCreateDefaultObjectFromCategoryId(SPCAT_AUDIOIN, &cpAudio);
      hr = cpEngine->SetInput(cpAudio, TRUE);
      hr = cpEngine->CreateRecoContext(&cpRecoCtx);
      hr = cpEngine->SetRecognizer(NULL);
      hr = cpRecoCtx->CreateGrammar(1, &cpGram);
      hr = cpGram->LoadDictation(L"Medical", SPLO_STATIC);

【问题讨论】:

  • 您应该能够使用 inproc 引擎中的主题。你能展示你的代码吗?
  • Inproc 识别器是“shell”。您需要指定识别引擎和输入源。在加载听写主题之前,您可能实际上没有绑定识别引擎,这将失败。
  • 我已经添加了我的代码。

标签: windows speech-recognition sapi


【解决方案1】:

Inproc 识别器没有默认的 SR 引擎,因此调用

hr = cpEngine->SetRecognizer(NULL);

实际上不会加载引擎。我写了一个简单的函数来加载默认识别器;代码比较长,所以我不会把它内联,但你可以找到它here

另外,在您的other question, 中,您的主题名为“医学”,而这里您将其命名为“医学”;它们确实需要相同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-22
    • 1970-01-01
    相关资源
    最近更新 更多