Microsoft Speech API(SAPI)UserTraining语法

时间:2015-05-04 20:02:49

标签: sapi

我有一个工作的autohotkey脚本,它会调出Windows语音识别培训界面,并提供自定义文本输入。 如果您已经完成了Windows语音识别的培训,您知道它说了一小段文本,然后一旦识别出该行,就会转到另一个短文本行的新屏幕。

我无法弄清楚如何将我的两句话文本“分解”为两个单独的训练屏幕,这样用户就不必同时阅读数千行训练文本而不会出错。

如果有人想到这一点,我会永远爱你

enter image description here

2 个答案:

答案 0 :(得分:0)

未测试

hwnd:=WinExist("A")
Title:="My App's Training"
RC := ComObjCreate("SAPI.SpSharedRecoContext")
MyTrainingText := new TrainingText("Some custom text", Title)
MyTrainingText.get_MyMethod()
MyTrainingText := new TrainingText("Some more training text", Title)
MyTrainingText.get_MyMethod()


Class TrainingText 
{
    __New(x, y)
    {
        this.Text := x
        this.Title := y
    }

    get_MyMethod()
    {
        Title := this.Title
        trainingText := this.Text
        if RC.Recognizer.IsUISupported("UserTraining")
        {
        RC.Recognizer.DisplayUI(ComObj(3,hwnd), Title, "UserTraining", traningText)
        }
        else MsgBox, Not supported
    }
}

答案 1 :(得分:0)

用户培训文本必须是double-null terminated string,也称为多字符串。每个以null结尾的子字符串将是一个单独的话语。我对AutoHotKey不熟悉,不知道如何使用该语言构建一个。

在C#中,将字符串数组转换为多字符串的函数如下所示:

static string StringArrayToMultiString(params string[] values)
{
    if (values == null) throw new ArgumentNullException("values");
    StringBuilder multiString = new StringBuilder();

    foreach (string s in values)
    {
        multiString.Append(s);
        multiString.Append('\0');
    }
    return multiString.ToString();
}
相关问题