Ses tanıma özelliğini bir hizmet olarak çalıştıran bir demo android uygulamasına (Android 4.0.3) sahibiz ve (sürekli olarak) tanıma sonuçlarını görünümde günlüğe kaydeder.Google Glass'da Android Voice Recognition (özel servis olarak) olması mümkün mü?
Akıllı telefonlarımızda her şey yolunda çalışıyor.
Biz bir Google Glass daldırma uygulamasında bu senaryoyu çoğaltmak istiyoruz, ama biz hizmeti başlatmaya çalıştığınızda her zaman bu hata mesajını vardır:
hiçbir seçilen ses tanıma hizmeti
bazı bilinen var mı sınırlamalar? Ya da birileri bu tür bir sorunu nasıl çözeceklerini anladı mı? Bu aktivitenin bazı önemli kod peşin
yılında
Teşekkür geçerli:
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));
}
...
}
Ve bu hizmetin kodudur:
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;
}
}
}
}
Kullanıcı izni etiketini uygulamanızın bildirimine eklediniz mi? –
emin: –
Ayrıca, şu anda bir çift gözlük mümkün mü? Tamam bunu unutma. Ses tanıma yönteminin GG'de nasıl çalıştığını biraz farklı düşünüyorum. [Buraya] bakın (https://developers.google.com/glass/develop/gdk/input/voice). –