我想通过说“你好,杰克”来唤醒Android APP中的一些功能。据我所知,有一种名为“短语发现”的技术可以识别某种语音,例如: “你好,杰克”。但我不知道实施“短语发现”。
任何人都有更多想法或建议吗?
感谢。
答案 0 :(得分:1)
最简单且资源效率最高的方法是为关键字定位实施动态时间扭曲DTW
http://en.wikipedia.org/wiki/Dynamic_time_warping
http://www.purduecal.edu/ece/WSEAS.pdf
您可以使用CMUSphinx工具包来提取MFCC功能,这将节省大量时间来实现它们
答案 1 :(得分:-1)
我首先建议这个简单的方法。
首先使用简单的Set来匹配您想要的关键字,如下所示:
public class WordMatcher
{
private Set<String> words;
public static final int NOT_IN = -1;
public WordMatcher(String... wordsIn)
{
this(Arrays.asList(wordsIn));
}
public WordMatcher(List<String> wordsIn)
{
//care about order so we can execute isInAt
words = new LinkedHashSet<String>(wordsIn);
}
public Set<String> getWords()
{
return words;
}
public boolean isIn(String word)
{
return words.contains(word);
}
public boolean isIn(String [] wordsIn)
{
boolean wordIn = false;
for (String word : wordsIn)
{
if (isIn(word))
{
wordIn = true;
break;
}
}
return wordIn;
}
像这样处理识别结果:
@Override
protected void
onActivityResult(int requestCode, int resultCode, Intent data)
{
WordMatcher matchHello = new WordMatcher("hello");
WordMatcher matchJack = new WordMatcher("jack");
if (requestCode == VOICE_RECOGNITION_REQUEST_CODE)
{
if (resultCode == RESULT_OK)
{
List<String> heard =
data.
getStringArrayListExtra
(RecognizerIntent.EXTRA_RESULTS);
for (String oneResult : heard)
{
if (matchHello.isIn(oneResult.split(" ")) && matchJack.isIn(oneResult.split(" "))
{
//SUCCESS!! do something here
}
}
}
else
{
Log.d(TAG, "error code: " + resultCode);
}
}
super.onActivityResult(requestCode, resultCode, data);
}
其次,如果失败则会引入“听起来像”匹配算法,例如Soundex。
此外,您可能希望直接使用SpeechRecognizer类在后台运行语音识别,而不是使用生成对话框的RecognizerIntent。