是否有可能有Android的语音识别(如定制服务)对谷歌玻璃? [英] Is it possible to have Android Voice Recognition (as a custom service) on Google Glass?
问题描述
我们有一个演示Android应用程序(安卓4.0.3)运行语音识别作为一种服务,(时间可持续)登录视图的识别结果。
We have a demo android application (Android 4.0.3) that runs voice recognition as a service, and (continuosly) logs the results of the recognition on the view.
一切工作在我们的智能手机就好了。
Everything is working fine in our smartphones.
我们想复制这种情况在谷歌玻璃浸泡应用程序,但我们一直有这样的错误消息,当我们试图启动服务:
We would like to replicate this scenario in a Google Glass immersion application, but we always have this error message when we try to start the service:
没有选择的语音识别服务
no selected voice recognition service
是否有一些已知的限制?或者有人想出如何解决这类问题呢?
Are there some known limitations? Or have someone figured out how to resolve this kind of problem?
在此先感谢
这是活动的一些显著code:
This is some significant code of the activity:
public class MainActivity extends Activity implements Observer {
...
@Override
protected void onStart() {
super.onStart();
//Toast.makeText(this, "Hi guys", Toast.LENGTH_LONG);
startService(new Intent(this, SilentVoiceRecognitionService.class));
}
...
}
这是服务的code:
And this is the code of the service:
public class SilentVoiceRecognitionService extends Service {
protected AudioManager mAudioManager;
protected SpeechRecognizer mSpeechRecognizer;
protected Intent mSpeechRecognizerIntent;
protected final Messenger mServerMessenger = new Messenger(new IncomingHandler(this));
private Model model = Model.getInstance();
static final String TAG = "SilentRecognizer";
static final int MSG_RECOGNIZER_START_LISTENING = 1;
static final int MSG_RECOGNIZER_CANCEL = 2;
protected boolean mIsListening;
@Override
public void onCreate()
{
super.onCreate();
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
mSpeechRecognizer.setRecognitionListener(new SpeechRecognitionListener());
mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE,
this.getPackageName());
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.i("LocalService", "Received start id " + startId + ": " + intent);
// We want this service to continue running until it is explicitly
// stopped, so return sticky.
mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
return START_STICKY;
}
@Override
public void onDestroy()
{
super.onDestroy();
if (mSpeechRecognizer != null)
{
mSpeechRecognizer.destroy();
}
}
protected class SpeechRecognitionListener implements RecognitionListener
{
...
}
protected static class IncomingHandler extends Handler
{
private WeakReference<SilentVoiceRecognitionService> mtarget;
IncomingHandler(SilentVoiceRecognitionService target)
{
mtarget = new WeakReference<SilentVoiceRecognitionService>(target);
}
@Override
public void handleMessage(Message msg)
{
final SilentVoiceRecognitionService target = mtarget.get();
switch (msg.what)
{
case MSG_RECOGNIZER_START_LISTENING:
if (!target.mIsListening)
{
target.mSpeechRecognizer.startListening(target.mSpeechRecognizerIntent);
target.mIsListening = true;
//Log.d(TAG, "message start listening"); //$NON-NLS-1$
}
break;
case MSG_RECOGNIZER_CANCEL:
target.mSpeechRecognizer.cancel();
target.mIsListening = false;
//Log.d(TAG, "message canceled recognizer"); //$NON-NLS-1$
break;
}
}
}
}
推荐答案
此功能已近日接受,但尚未公布,看到的 HTTPS://$c$c.google.com/p/google-glass-api/issues/detail ID = 245
This feature has been recently accepted but not yet available, see https://code.google.com/p/google-glass-api/issues/detail?id=245
您可以装载更多的提到的apk获得的平均时间的功能。 请参阅<一href="http://stackoverflow.com/questions/17414251/using-android-speech-recognition-apis-from-google-glass">Using从谷歌玻璃 Android的语音识别API的
You can load the additional mentioned apk to get the functionality for the mean time. See Using Android Speech Recognition APIs from Google Glass
这篇关于是否有可能有Android的语音识别(如定制服务)对谷歌玻璃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!