如何向默认 VoiceDialer 应用程序添加语法?
我正在尝试向 android 默认语音拨号器应用程序添加一些命令。它有打开、拨号、呼叫、重拨等命令,我想包括让我们对它说“查找”。我已经从此处 并在 Eclipse 中编译它。该应用程序为这些命令的参数设置语法,例如它存储联系人列表中人员的姓名和电话号码,以便在 CALL JOHN 语音命令识别他们的姓名时生成意图。对于此命令中的 CALL,它只是将生成的识别字符串的第一个单词与“CALL”进行比较。
我在 onRecognitionSuccess() 函数中添加了“FIND”作为额外的 else if 条件,如下所示:
public class CommandRecognizerEngine extends RecognizerEngine
{
............
protected void onRecognitionSuccess(RecognizerClient recognizerClient) throws InterruptedException
{
.....................
if ("DIAL".equalsIgnoreCase(commands[0]))
{
Uri uri = Uri.fromParts("tel", commands[1], null);
String num = formatNumber(commands[1]);
if (num != null)
{
addCallIntent(intents, uri, literal.split(" ")[0].trim() + " " + num, "", 0);
}
}
................
else if ("FIND".equalsIgnoreCase(commands[0]))
{
if (Config.LOGD)
Log.d(TAG, "FIND detected...");
}
}//end onRecognitionSuccess
}//end CommandRecognizerEngine
但我的应用程序无法识别它。有谁知道识别器如何检测诸如 OPEN 或 CALL 等命令或向我推荐适当的文档?
谢谢。
I am trying to add a few commands to android default voicedialer app. It has commands like Open, dial, call, redial etc, I want to include lets say 'Find' to it. I have downloaded the source code from here and compiled it in Eclipse. the application sets up Grammar for arguments of these commands like it stores the names and phone numbers of the persons in contact list to generate intents when their names are recognized for CALL JOHN voice command. For CALL in this command it is just comparing the first word of resulting recognized string to "CALL".
I added "FIND" as an extra else if condition in the onRecognitionSuccess() function as shown below:
public class CommandRecognizerEngine extends RecognizerEngine
{
............
protected void onRecognitionSuccess(RecognizerClient recognizerClient) throws InterruptedException
{
.....................
if ("DIAL".equalsIgnoreCase(commands[0]))
{
Uri uri = Uri.fromParts("tel", commands[1], null);
String num = formatNumber(commands[1]);
if (num != null)
{
addCallIntent(intents, uri, literal.split(" ")[0].trim() + " " + num, "", 0);
}
}
................
else if ("FIND".equalsIgnoreCase(commands[0]))
{
if (Config.LOGD)
Log.d(TAG, "FIND detected...");
}
}//end onRecognitionSuccess
}//end CommandRecognizerEngine
but my app can't recognize it. Does anyone know how does recognizer detects commands like OPEN or CALL etc or refer me to appropriate documentation?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
已经过去一年多了,我怀疑您是否还需要这个答案。然而,其他一些人可能会像我一样通过谷歌找到这个。
目前,将语法应用于 Android 语音识别的最佳方法是将结果数量设置得更高,然后根据语法过滤结果。它并不完美,因为识别的单词可能没有通过包含在列表中的阈值,但它确实极大地提高了所有语音识别应用程序的准确性,在这些应用程序中,您可以说的内容类型有些有限。
As it has been over a year, I doubt you need this answer anymore. However, some other people might find this through Google, as I did.
Right now, the best way to apply grammars to speech recognition on Android is to set the number of results higher, and then filter the results based on your grammar. It is not perfect, as the word recognized may not have passed a threshold to be included in the list, but it does greatly improve the accuracy of all speech recognition applications where the types of things you can say are somewhat limited.