Split hypothesis on individual keyphrases

拈花ヽ惹草 提交于 2019-12-20 05:42:23

问题


I use Pocketsphinx in my Android app. I have a relatively small set of commands to be recognized independently, so I ended up using a keyword search from a file that looks like this:

one/1.0/
done/1.0/
recognition on/1e-10/
recognition off/1e-10/

The actual list is not in English so these keywords are chosen arbitrarily for the sake of the example. I realize that these thresholds may be somewhat less than optimal, and that short words are prone to mismatches.

The problem arises in this method:

@Override
public void onPartialResult(Hypothesis hypothesis) {
    if (hypothesis != null) {
        Log.d(
                "Sphinx",
                "\"" + hypothesis.getHypstr() + "\" recognized"
        );
    }
}

Note that some words sound pretty much alike. The thing is,

  • "One" results in "done one" recognized
  • "Done" results in "one done" recognized

Unfortunately, I couldn't find any documentation on hypstr_get (I would appreciate if you could direct me to it) but effectively it seems to return a joined string of probable matches in increasing order of probability.

How can I retrieve actual commands from hypothesis? I can't just split hypothesis.getHypstr() by whitespace since some commands are keyphrases rather than keywords. I only want a single, most probable result.

Thanks.


回答1:


You can iterate over segments, each would be a keyword

    for (Segment seg : recognizer.getDecoder().seg()) {
        System.out.println(seg.getWord() + " " + seg.getProb());
    }


来源:https://stackoverflow.com/questions/40412843/split-hypothesis-on-individual-keyphrases

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!