有没有人知道在SAPI中以编程方式创建和/或选择语音配置文件的方法?

时间:2010-09-24 17:51:13

标签: speech-recognition sapi

我需要为用户提供一种简单的方法,无需进入控制面板,即可选择语音配置文件。 我发现: Acoustic training using SAPI 5.3 Speech API 但没有例子,信息不完整。

我真的可以使用一个例子,如果有人有一个:)

2 个答案:

答案 0 :(得分:1)

“语音控制面板”旁边带有“复选框”的“默认”配置文件由注册表项决定:

[HKEY_CURRENT_USER\Software\Microsoft\Speech\RecoProfiles]
"DefaultTokenId"="HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech\\RecoProfiles\\Tokens\\{A32BEAC3-4442-4E13-B485-8A2DD7178794}"

我认为只有在Windows语音识别GUI /控制面板启动时才会读取此配置设置。因此,直接修改此注册表值可能对“在运行时”更改配置文件没有用。

要在运行时更改配置文件,您可以考虑使用SetRecoProfile功能。达到可以调用该功能的点是一个涉及的主题,但是......

答案 1 :(得分:1)

以下代码段可能有助于选择识别配置文件。我还没有尝试以编程方式创建新的配置文件。

IEnumSpObjectTokens *pProfileEnum;
SpEnumTokens(SPCAT_RECOPROFILES, NULL, NULL, &pProfileEnum);

unsigned long l;
pProfileEnum->GetCount(&l);

for (int i = 0; i < (int) l; i++)
{
    CComPtr<ISpObjectToken> IT;
    pProfileEnum->Item(i, &IT);
    WCHAR *wptr;
    IT->GetId(&wptr);
    CSpDynamicString dstrDefaultName;
    SpGetDescription(IT, &dstrDefaultName);
    //Do something to select the profile withe the name you would like to use
}  


//Assuming IT is the profile you want to use, activat it by calling:
cpRecognizer->SetRecoProfile(IT);