我想通过说“你好,杰克”来唤醒 Android APP 中的一些功能。据我所知,有一种名为“短语识别”的技术可以识别特定的语音,例如“你好,杰克”。但我不知道实施“短语发现”。
任何人有更多的想法或建议?
谢谢。
我想通过说“你好,杰克”来唤醒 Android APP 中的一些功能。据我所知,有一种名为“短语识别”的技术可以识别特定的语音,例如“你好,杰克”。但我不知道实施“短语发现”。
任何人有更多的想法或建议?
谢谢。
最简单且资源高效的方法是为关键字发现实施动态时间扭曲 DTW
http://en.wikipedia.org/wiki/Dynamic_time_warping
http://www.purduecal.edu/ece/WSEAS.pdf
您可以使用 CMUSphinx 工具包来提取 MFCC 特征,这将节省大量实施它们的时间
我首先建议这种简单的方法。
首先使用一个简单的 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 进行调查。