¿Es posible tener Android Voice Recognition (como un servicio personalizado) en Google Glass?
Tenemos una aplicación demo android (Android 4.0.3) que ejecuta reconocimiento de voz como un servicio, y (continuamente) registra los resultados del reconocimiento en la vista.
Todo está funcionando bien en nuestros teléfonos inteligentes.
- Diálogo de alerta del servicio de Android
- Android: Pasar variables a un servicio ya en ejecución
- El servicio de fondo de Android se está reiniciando cuando se cancela la aplicación
- Servicio en android?
- El servicio no se inició en BOOT COMPLETE
Nos gustaría reproducir este escenario en una aplicación de inmersión de Google Glass, pero siempre tenemos este mensaje de error cuando intentamos iniciar el servicio:
Ningún servicio de reconocimiento de voz seleccionado
¿Hay algunas limitaciones conocidas? ¿O alguien ha descubierto cómo resolver este tipo de problema?
Gracias por adelantado
Este es un código significativo de la actividad:
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)); } ... }
Y este es el código del servicio:
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; } } }
}
- AudioSource.VOICE_CALL no funciona en android 4.0 pero funciona en android 2.3
- Obtener una vista de AccessibilityNodeInfo para crear superposición
- Appcelerator Android Service detiene las paradas
- Android Bluetooth desde dentro del servicio
- Permiso denegado cuando intento iniciarServicio
- ¿Cómo iniciar un servicio Android desde una actividad y detener el servicio en otra actividad?
- android onTaskRemoved () no llamado en mi (xiomi)
- Android - el servicio se detiene cuando se destruye la actividad
Esta función se ha aceptado recientemente pero aún no está disponible, consulte https://code.google.com/p/google-glass-api/issues/detail?id=245.
Puede cargar el apk adicional mencionado para obtener la funcionalidad por el tiempo medio. Consulte Utilización de las API de reconocimiento de voz de Android de Google Glass
A partir de XE16 ahora es posible utilizar SpeechRecognizer directamente y obtener los resultados a través de SpeechRecognitionListener.
Desafortunadamente esto todavía no funciona dosen't fuera de línea.
- Cómo cancelar o descartar un cuadro de diálogo personalizado en su método onCreate?
- Cómo configurar los sabores para android gradle proyecto? Misterioso error de clase duplicado