在Android的语音识别的比较使用:由意向或线程? [英] Comparison of Speech Recognition use in Android: by Intent or on-thread?

查看:164
本文介绍了在Android的语音识别的比较使用:由意向或线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android提供给我使用语音识别两种方式。

Android provides two ways for me to use speech recognition.

首先办法是由意图,因为在这个问题:的意向例如。新活动被压在其上监听到用户堆栈的顶部,听到一些言论,试图(通常通过云)来录制它,然后返回结果给我应用程序,通过 onActivityResult 电话。

The first way is by an Intent, as in this question: Intent example. A new Activity is pushed onto the top of the stack which listens to the user, hears some speech, attempts to transcribes it (normally via the cloud) then returns the result to my app, via an onActivityResult call.

第二是得到一个 SpeechRecognizer ,如code在这里:的 SpeechRecognizer例如的。在这里,它看起来像语音记录并转录到其它线程,则回调给我带来的结果。而做到这一点的没有留下我的活动 的。

The second is by getting a SpeechRecognizer, like the code here: SpeechRecognizer example. Here, it looks like the speech is recorded and transcribed on some other thread, then callbacks bring me the results. And this is done without leaving my Activity.

我想明白做语音识别这两种方法

I would like to understand the pros and cons of these two ways of doing speech recognition.

使用意图

  • 是简单的code
  • 避免重蹈覆辙
  • 在给语音识别跨设备
  • 一致的用户体验
  • is simple to code
  • avoids reinventing the wheel
  • gives consistent user experience of speech recognition across the device

  • 可能是为创造有一个新的活动缓慢自己的窗口

使用 SpeechRecognizer

  • 让我留住用户界面控制我的应用程序
  • 在给我的东西多的可能性,以(<一回应href="http://developer.android.com/reference/android/speech/RecognitionListener.html">documentation)

  • 从主线程调用被限制
  • 更多的控制需要更多的错误检查。

推荐答案

在除了这一切,我想至少添加了这一点:

In addition to all this, I'd add at least this point:

SpeechRecognizer 是免提的用户界面更好,因为你的应用程序实际上得到响应的错误,如不匹配的条件和可能自行重新启动。当您使用意图,应用程序发出蜂鸣声,并显示一个对话框,用户必须preSS继续。

SpeechRecognizer is better for hands-free user interfaces, since your app actually gets to respond to error conditions like "No matches" and perhaps restart itself. When you use the Intent, the app beeps and shows a dialog that the user must press to continue.

我总结如下:

SpeechRecognizer

SpeechRecognizer

  • 显示不同的UI或没有UI可言。你真的想你的应用程序的用户界面发出蜂鸣声?你真的想你的UI显示一个对话框时,出现错误,等待用户点击?

  • Show different UI or no UI at all. Do you really want your app's UI to beep? Do you really want your UI to show a dialog when there is an error and wait for user to click?

应用程序可以做别的事情,而语音识别正在发生的事情

App can do something else while speech recognition is happening

可以识别语音的背景下或从运行时 服务

Can recognize speech while running in the background or from a service

可以处理错误更好

可以访问低级言语的东西,如原始音频或RMS。分析该音频,或使用音量做出某种闪烁的灯光来指示应用程序正在听

Can access low level speech stuff like the raw audio or the RMS. Analyze that audio or use the loudness to make some kind of flashing light to indicate the app is listening

意图

  • 一致的,且易于使用的用户界面,为用户
  • 易于编程

这篇关于在Android的语音识别的比较使用:由意向或线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆