关键字发现:假设是空的,直到它恰好是您要查找的关键字之一
Keywords spotting: hypotesis is null until it is exactly one of the keyword you are looking for
我正在使用 onPartialResult
方法来查看 hypotesis
是否是我感兴趣的关键字之一并且效果很好。
这是我的代码:
@Override
public void onPartialResult(Hypothesis hypothesis) {
Log.d(TAG, "onPartialResult");
if (hypothesis == null) {
return;
}
String text = hypothesis.getHypstr();
String wordWithProb = "";
String mostProbableWord = "";
int probability = -10000;
if (text.contains("|")) {
for (Segment seg : recognizer.getDecoder().seg()) {
wordWithProb += "|" + seg.getWord() + " " + seg.getProb() + "|";
if (seg.getProb() > probability)
mostProbableWord = seg.getWord().trim();
}
}
else
mostProbableWord = text.trim();
Log.i(TAG, "onPartialResults: " + mostProbableWord);
String recognizedCommand = "Please repeat";
if (mostProbableWord.equals("one")) {
//do something...
} else if (mostProbableWord.equals("two")) {
//do something...
} else if (mostProbableWord.equals("three")) {
//do something...
}
//text to speech
speak(recognizedCommand);
startListening(KWS_SEARCH);
}
现在我想处理用户说了些什么但不被识别为关键字的情况;在这种情况下,onPartialResult
方法中的假设总是 null
:这是预期的吗? 我期待这里的假设不为空...
考虑到 onPartialResult
方法被 pocketsphinx 连续自动调用(即使空气中没有任何声音)我不能使用 null
假设作为我的驾驶条件。
此外,每次识别后都有一个文本到语音,因此必须小心处理识别侦听器的重启:在文本到语音正在进行时,识别器不能正在收听...
我用 onEndOfSpeech
尝试了一些解决方案,但 none 直到现在都很好......
有什么想法吗?
in this case the hypotesis in the onPartialResult method is always null: is this expected?
是
Moreover there is a text to speech after every recognition and so the recognition listener restart has to be handled carefully: recognizer must not be listening while text to speech is ongoing
正确
我正在使用 onPartialResult
方法来查看 hypotesis
是否是我感兴趣的关键字之一并且效果很好。
这是我的代码:
@Override
public void onPartialResult(Hypothesis hypothesis) {
Log.d(TAG, "onPartialResult");
if (hypothesis == null) {
return;
}
String text = hypothesis.getHypstr();
String wordWithProb = "";
String mostProbableWord = "";
int probability = -10000;
if (text.contains("|")) {
for (Segment seg : recognizer.getDecoder().seg()) {
wordWithProb += "|" + seg.getWord() + " " + seg.getProb() + "|";
if (seg.getProb() > probability)
mostProbableWord = seg.getWord().trim();
}
}
else
mostProbableWord = text.trim();
Log.i(TAG, "onPartialResults: " + mostProbableWord);
String recognizedCommand = "Please repeat";
if (mostProbableWord.equals("one")) {
//do something...
} else if (mostProbableWord.equals("two")) {
//do something...
} else if (mostProbableWord.equals("three")) {
//do something...
}
//text to speech
speak(recognizedCommand);
startListening(KWS_SEARCH);
}
现在我想处理用户说了些什么但不被识别为关键字的情况;在这种情况下,onPartialResult
方法中的假设总是 null
:这是预期的吗? 我期待这里的假设不为空...
考虑到 onPartialResult
方法被 pocketsphinx 连续自动调用(即使空气中没有任何声音)我不能使用 null
假设作为我的驾驶条件。
此外,每次识别后都有一个文本到语音,因此必须小心处理识别侦听器的重启:在文本到语音正在进行时,识别器不能正在收听...
我用 onEndOfSpeech
尝试了一些解决方案,但 none 直到现在都很好......
有什么想法吗?
in this case the hypotesis in the onPartialResult method is always null: is this expected?
是
Moreover there is a text to speech after every recognition and so the recognition listener restart has to be handled carefully: recognizer must not be listening while text to speech is ongoing
正确