我试了很多,但都没找到,所以我希望你能帮助我。
我正在尝试构建我自己的语音识别应用程序,它不会显示对话框。
我已经编写了一些代码,它工作得很好,但我的问题是,识别器似乎停止了,而LogCat中没有任何错误或其他消息。
一个奇怪的事实是,“RecognitionListener”接口中的“onRmsChanged”仍然一直被调用,但不再调用“onBeginningOfSpeech”。
如果我在语音识别开始后说话,它就会工作。但是如果我等几秒钟就不会了。
使用的API是4.0.3,我将其安装在Nexus 7上,版本为4.2.1
如果你有一些好主意,我将不胜感激。
一些代码片段:
我的班级:
class SpeechListener implements RecognitionListener
{
public void onBeginningOfSpeech()
{
Log.d(TAG, "onBeginningOfSpeech()");
}
public void onBufferReceived(byte[] buffer)
{
Log.d(TAG, "onBufferReceived()");
}
public void onEndOfSpeech()
{
Log.d(TAG, "onEndOfSpeech()");
}
public void onError(int error)
{
Log.d(TAG, "onError(): " + error);
if(error == SpeechRecognizer.ERROR_NO_MATCH)
{
}
else if(error == SpeechRecognizer.ERROR_SPEECH_TIMEOUT)
{
}
else
{
tvOutput.setText("Error: " + error);
}
}
public void onEvent(int eventType, Bundle params)
{
Log.d(TAG, "onEvent()");
}
public void onPartialResults(Bundle partialResults)
{
Log.d(TAG, "onPartialResults()");
}
public void onReadyForSpeech(Bundle params)
{
Log.d(TAG, "onReadyForSpeech()");
}
public void onResults(Bundle results)
{
Log.d(TAG, "onResults(): " + results);
String str = new String();
ArrayList<String> data = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
for(int i = 0; i < data.size(); i++)
{
str += data.get(i) + "\n";
}
tvOutput.setText(tvOutput.getText().toString() + "\n\n" + "Results: " + str);
}
public void onRmsChanged(float rmsdB)
{
Log.d(TAG, "onRmsChanged()");
}
}
以及我在主要活动中的实施:
this.srSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
this.srSpeechRecognizer.setRecognitionListener(new SpeechListener());
this.iSpeechIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
this.iSpeechIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
this.iSpeechIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, "voice.recognition.test");
this.iSpeechIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 10);
就这样开始了:
srSpeechRecognizer.startListening(iSpeechIntent);
用语音记录:
12-16 13:50:53.576: D/DreamManagerService(485): Dream finished: android.os.Binder@415bbf38
12-16 13:50:53.576: I/DreamManagerService(485): Leaving dreamland.
12-16 13:50:53.576: I/DreamController(485): Stopping dream: name=ComponentInfo{com.google.android.deskclock/com.android.deskclock.Screensaver}, isTest=false, userId=0
12-16 13:50:53.586: I/PowerManagerService(485): Waking up from dream...
12-16 13:50:53.616: I/ActivityManager(485): No longer want com.google.android.gsf.login (pid 13171): empty #17
12-16 13:50:56.796: I/GoogleRecognitionServiceImpl(1461): #startListening [de-DE]
12-16 13:50:56.806: I/ActivityManager(485): Start proc com.google.android.gsf.login for service com.google.android.gsf.login/com.google.android.gsf.loginservice.GoogleLoginService: pid=13343 uid=10019 gids={50019, 3003, 1007, 1028, 1015, 2001, 3006}
12-16 13:50:56.866: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:56.886: D/dalvikvm(1461): GC_FOR_ALLOC freed 516K, 12% free 8706K/9892K, paused 18ms, total 18ms
12-16 13:50:56.906: D/dalvikvm(1461): GC_CONCURRENT freed 160K, 9% free 9015K/9892K, paused 3ms+2ms, total 21ms
12-16 13:50:56.906: I/AudioService(485): AudioFocus requestAudioFocus() from android.media.AudioManager@4135e960com.google.android.speech.audio.AudioController$1@41261910
12-16 13:50:56.916: I/VS.G3EngineManager(1461): create_rm: m=ENDPOINTER_VOICESEARCH,l=en-US
12-16 13:50:56.916: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:56.916: I/VS.G3EngineManager(1461): Brought up new g3 instance :/system/usr/srec/en-US/endpointer_voicesearch.config for: en-USin: 3 ms
12-16 13:50:56.926: I/ConnectionFactoryImpl(1461): Opening SSL connection: vs.google.com:14259
12-16 13:50:56.966: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.016: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.066: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.116: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.166: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.216: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.266: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.316: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.366: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.416: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.466: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.516: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.566: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.616: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.666: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.716: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.766: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.816: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.866: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.916: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:57.966: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.016: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.066: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.116: I/MainActivity/SpeechListener(13268): onBeginningOfSpeech()
12-16 13:50:58.126: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.176: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.226: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.276: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.326: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.376: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.426: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.476: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.526: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.576: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.626: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.676: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.726: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.776: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.826: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.876: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.926: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:58.976: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.026: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.076: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.126: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.176: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.236: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.286: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.336: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.386: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.436: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.486: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.536: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.586: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.636: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.646: I/MicrophoneInputStream(1461): mic_close
12-16 13:50:59.666: I/AudioService(485): AudioFocus abandonAudioFocus() from android.media.AudioManager@4135e960com.google.android.speech.audio.AudioController$1@41261910
12-16 13:50:59.666: D/dalvikvm(1461): threadid=37: thread exiting, not yet detached (count=0)
12-16 13:50:59.666: I/MainActivity/SpeechListener(13268): onEndOfSpeech()
12-16 13:50:59.676: I/decoder(1461): INFO: recognition time wall: 2.732 sec user: 0.54 sec sys: 0.08 sec
12-16 13:50:59.686: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.736: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.786: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.826: I/MainActivity/SpeechListener(13268): onResults(): Bundle[mParcelledData.dataSize=292]
12-16 13:50:59.836: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.886: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.936: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:50:59.986: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:51:00.046: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:51:00.096: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:51:00.146: D/MainActivity/SpeechListener(13268): onRmsChanged()
12-16 13:51:00.196: D/MainActivity/SpeechListener(13268): onRmsChanged()
不说话的日志:
12-16 13:53:39.246: I/GoogleRecognitionServiceImpl(1461): #startListening [de-DE]
12-16 13:53:39.296: D/dalvikvm(1461): GC_FOR_ALLOC freed 567K, 12% free 8708K/9892K, paused 21ms, total 21ms
12-16 13:53:39.316: D/dalvikvm(1461): GC_CONCURRENT freed 164K, 9% free 9017K/9892K, paused 3ms+2ms, total 21ms
12-16 13:53:39.316: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.316: I/AudioService(485): AudioFocus requestAudioFocus() from android.media.AudioManager@4135e960com.google.android.speech.audio.AudioController$1@41261910
12-16 13:53:39.326: I/VS.G3EngineManager(1461): create_rm: m=ENDPOINTER_VOICESEARCH,l=en-US
12-16 13:53:39.326: I/ConnectionFactoryImpl(1461): Opening SSL connection: vs.google.com:14259
12-16 13:53:39.326: I/VS.G3EngineManager(1461): Brought up new g3 instance :/system/usr/srec/en-US/endpointer_voicesearch.config for: en-USin: 5 ms
12-16 13:53:39.366: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.416: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.466: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.516: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.576: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.626: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.676: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.726: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.776: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.826: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.876: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.926: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:39.976: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.026: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.076: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.136: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.176: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.226: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.286: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.336: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.386: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.436: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.486: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.536: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.586: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.636: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.686: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.736: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.786: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.836: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.886: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.936: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:40.986: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.046: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.096: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.146: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.196: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.246: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.296: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.346: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.396: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.446: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.496: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.546: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.596: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.646: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.696: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.746: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.796: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.846: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.896: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.946: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:41.996: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.046: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.096: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.146: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.196: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.246: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.296: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.356: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.406: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.456: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.506: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.556: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.606: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.656: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.706: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.756: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.806: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.856: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.906: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:42.956: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.006: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.056: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.116: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.156: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.216: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.266: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.316: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.366: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.416: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.466: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.516: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.566: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.616: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.666: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.716: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.766: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.816: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.866: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.916: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:43.966: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.016: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.066: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.116: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.166: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.226: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.276: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.326: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.376: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.426: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.476: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.526: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.576: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.626: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.676: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.726: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.776: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.826: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.876: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.926: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:44.976: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.026: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.076: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.126: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.176: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.226: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.276: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.326: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.376: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.426: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.476: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.526: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.576: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.636: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.676: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.736: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.786: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.836: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.886: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.936: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:45.986: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.036: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.086: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.136: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.186: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.236: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.286: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.336: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.386: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.436: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.486: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.536: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.596: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.636: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.696: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.746: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.796: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.846: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.896: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.946: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:46.996: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.046: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.096: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.146: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.196: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.246: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.296: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.346: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.396: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.446: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.496: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.556: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.596: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.656: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.696: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.746: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.796: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.856: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.906: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:47.956: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.006: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.056: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.106: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.156: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.206: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.256: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.306: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.356: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.406: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.456: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.506: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.556: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.616: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.656: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.706: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.766: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.816: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.866: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.916: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:48.966: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.016: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.066: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.116: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.166: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.216: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.266: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.316: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.366: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.416: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.466: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.516: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.566: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.616: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.666: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.716: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.776: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.816: D/dalvikvm(1461): GC_FOR_ALLOC freed 106K, 9% free 9025K/9892K, paused 32ms, total 32ms
12-16 13:53:49.816: I/dalvikvm-heap(1461): Grow heap (frag case) to 9.282MB for 320656-byte allocation
12-16 13:53:49.836: D/dalvikvm(1461): GC_FOR_ALLOC freed 156K, 11% free 9182K/10208K, paused 19ms, total 19ms
12-16 13:53:49.836: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.886: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.936: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:49.986: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:50.036: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:50.086: D/MainActivity/SpeechListener(13441): onRmsChanged()
12-16 13:53:50.136: D/MainActivity/SpeechListener(13441): onRmsChanged()
您可以尝试提供以下识别意图附加功能:
EXTRA\u SPEECH\u INPUT\u COMPLETE\u SILENCE\u LENGTH\u MILLIS
虽然没有一个真正适合这种情况。Android根本不提供额外的“WAIT\u UNTIL\u START\u SPEAKING”
。这不是一个bug(在Jelly Bean或任何地方),只是缺少一个特性。即使在未来的Android版本中添加了这样的额外功能,也可能无法保证语音识别应用程序(如谷歌语音搜索)能够真正实现这一功能。RecognizerIntent文档包含大量具有未指定行为的额外内容。
您最好的选择可能是在您获得OneDofspeech或OneError后立即重新启动识别器。
我做了一个带有音频到语音识别器的服务,该识别器通过每次出现错误或结果时重新启动自身来模拟连续。如您所见,我的服务会监听广播接收器以启动/停止连续ASR(电池很贵,所以我建议您仅在相关UI在前台时运行此连续ASR服务)。ASR的结果也会广播到应用程序的其余部分。您可以忽略广播,服务和识别器监听器是主要思想。DONT忘记INTERNET权限和清单,以及服务声明:
<service android:name=".speechRecognitionService" />
SpeechRecognitionService:
/**
* Created by Josh on 22/07/15.
* This service bears an Audio to Speech recognizer (ASR), once this service is started,
* it listens a broadcast called "asrService".
* the Service starts ASR when it receives a "START-ASR" value inside the "message" parameter of its broadcast receiver
* the Service stopss ASR when it receives a "STOP-ASR" value inside the "message" parameter of its broadcast receiver
Example:
Intent intent = new Intent("asrService");
intent.putExtra("message", "STOP-ASR");
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
Once the ASR Listener that this service bears is running, it will broadcast the results is gets.
To catch ASR results, implement a Broadcast receiver that listens to app.asrResult="ASRresult", for example:
private BroadcastReceiver ASRReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getStringExtra("message");
if(message!=null) {
app.logwhite("ASR says: "+message);
}
}
};
LocalBroadcastManager.getInstance(this).registerReceiver(ASRReceiver, new IntentFilter(app.asrResult));
Unregister the broadcast receiver likewise:
LocalBroadcastManager.getInstance(this).unregisterReceiver(ASRReceiver);
*/
public class speechRecognitionService extends Service {
private static speechRecognitionListenerJosh speechReconListener;
private static SpeechRecognizer mSpeechRecognizer=null;
private static Intent mSpeechRecognizerIntent;
private static boolean mIslistening=false;
//======== BROADCAST RECEIVERS
// handler for received Intents for the "my-event" event
private BroadcastReceiver startASRReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String message = intent.getStringExtra("message");
if(message.equals("START-ASR")) {
if (mIslistening == false) {
if (mSpeechRecognizer != null) {
mSpeechRecognizer.destroy();
mSpeechRecognizer = null;
}
app.logy("==BROADCAST Rx: START_ASR");
mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en-US");
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
//mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE , this.getPackageName());
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, 5000);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 5000);
//mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_PARTIAL_RESULTS, true);
//mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(getApplicationContext());
speechReconListener = new speechRecognitionListenerJosh();
mSpeechRecognizer.setRecognitionListener(speechReconListener);
mSpeechRecognizer.startListening(mSpeechRecognizerIntent);
} else {
app.logy("==BROADCAST Rx: STOP_ASR");
mSpeechRecognizer.stopListening();
mSpeechRecognizer.destroy();
speechReconListener = null;
}
}
if(message.equals("STOP-ASR")){
app.logy("==BROADCAST Rx: STOP_ASR");
mSpeechRecognizer.stopListening();
mSpeechRecognizer.destroy();
speechReconListener = null;
}
}
};
@Override
public void onCreate() {
super.onCreate();
mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "en-US");
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL , RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
//mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE , this.getPackageName());
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 4000);
mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 3);
mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
speechReconListener = new speechRecognitionListenerJosh();
mSpeechRecognizer.setRecognitionListener(speechReconListener);
LocalBroadcastManager.getInstance(this).registerReceiver(startASRReceiver, new IntentFilter("asrService"));
app.toastlog("==ASR Service - CREATED");
}
@Override
public void onDestroy() {
super.onDestroy();
LocalBroadcastManager.getInstance(this).unregisterReceiver(startASRReceiver);
if (mSpeechRecognizer != null){
mSpeechRecognizer.destroy();
mSpeechRecognizer=null;
}
app.toastlog("==ASR Service - DESTROYED");
}
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override //rather not use, runs before onStart
public int onStartCommand(Intent intent, int flags, int startId) {
return super.onStartCommand(intent, flags, startId);
}
@Override
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
app.toastlog("==ASRservice - onStart");
}
private class speechRecognitionListenerJosh implements RecognitionListener {
@Override
public void onBeginningOfSpeech() {
mIslistening=true;
app.loge("=ASRListener - onBeginingOfSpeech");
}
@Override
public void onBufferReceived(byte[] buffer){
}
@Override
public void onEndOfSpeech(){
app.loge("=ASRListener - onEndOfSpeech");
}
@Override
public void onError(int error) {
mIslistening=false;
String code= Integer.toString(error);
if(error==SpeechRecognizer.ERROR_CLIENT){ // 5
code="ERROR_CLIENT";
mIslistening=false;
mSpeechRecognizer.destroy();
Intent intent = new Intent("asrService");
intent.putExtra("message", "START-ASR");
LocalBroadcastManager.getInstance(app.appContext).sendBroadcast(intent);
}
if(error==SpeechRecognizer.ERROR_SPEECH_TIMEOUT){ // 6
code="SPEECH_TIMEOUT";
mSpeechRecognizer.stopListening();
mIslistening=false;
Intent intent = new Intent("asrService");
intent.putExtra("message", "START-ASR");
LocalBroadcastManager.getInstance(app.appContext).sendBroadcast(intent);
//Usualy bounces back to ERROR_CLIENT.
}
if(error==SpeechRecognizer.ERROR_NO_MATCH){ // 7
code="ERROR_NO_MATCH";
mIslistening=false;
Intent intent = new Intent("asrService");
intent.putExtra("message", "START-ASR");
LocalBroadcastManager.getInstance(app.appContext).sendBroadcast(intent);
//Usually bounces back to ERROR_CLIENT.
}
app.loge("=ASRListener - ASR Error: "+code);
/*
// 1 = NETWORK_TIMEOUT
// 2 = ERROR_NETWORK
// 3 = ERROR_AUDIO
// 4 = ERROR_SERVER
// 5 = ERROR_CLIENT
// 8 = ERROR_RECOGNIZER_BUSY
// 9 = ERROR_INSUFFICIENT_PERMISSIONS
*/
}
@Override
public void onEvent(int eventType, Bundle params){
}
@Override //Somehow doesn't trigger upon partial results
public void onPartialResults(Bundle partialResults){
ArrayList<String> results=partialResults.getStringArrayList("EXTRA_PARTIAL_RECOGNITION");
if(results!=null) {
if (results.size() > 0) {
app.logwhite("=== ASR Partial Results: " + results);
}
}
}
@Override
public void onReadyForSpeech(Bundle params){
app.loge("=ASRListener - onReadyForSpeech, LISTENING (((( ");
}
@Override
public void onResults(Bundle resultBundle){
app.loge("=ASRListener - onResults");
ArrayList<String> result = resultBundle.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
if(result!=null) { //when speaking timeout happen, results is null
// matches are the return values of speech recognition engine
if (result.size() > 0) {
app.logwhite("=== ASR Results:");
app.logwhite(result.get(0));
//BC name, message
app.broadcast(app.asrResult,result.get(0)); //The result is broadcast to the entire app
}
}
mIslistening=false;
Intent intent = new Intent("asrService");
intent.putExtra("message", "START-ASR");
LocalBroadcastManager.getInstance(app.appContext).sendBroadcast(intent);
}
@Override
public void onRmsChanged(float rmsdB){
//VOLUME VUmeter!!!!
}
}
}
唯一可以解决这个问题的解决方案是使用第三方服务。4.1.1和4.2都依赖于不遵守记录行为的语音识别服务版本,因为运行它的服务会无声地终止。
如果您不希望使用第三方API,并且您需要以某种方式解释此服务死亡,这是可能的,但它并不漂亮或理想。
一旦服务死亡,将永远不会调用以下任何方法:
但如果在服务终止之前调用onBeginningOfSpeech,您可以确信最终将调用onError或onEndOfSpeech。
因此,如果您想要的只是确保您了解Jellybean中服务的生死存亡,那么内置语音识别器中此问题的解决方法是执行以下操作:
为什么这不是维护连续语音识别设置的理想解决方案
你的问题中没有直接说明这一点,但有几个人想这样做,这样他们就可以进行连续语音识别。在4.1.1和4.2中,这并不是一个很好的方法,因为谷歌的语音识别服务现在以一个非可选的“bloop”声音效果开始。似乎无法关闭此声音。API中没有列出任何内容来控制它。您的用户不会喜欢在4秒的重复循环中被“吹”出来。
我已经在上安装了Sonar,所有先决条件都是Mysql和Java。在控制台模式下启动服务时,将出现以下错误消息: 甚至,wrapper.properties文件中也配置了Java环境变量,但问题仍然存在。 来人,帮我解决这个问题。 在下面的wrapper.java.command(wrapper.properties)中设置Java路径后,将出现错误。 正在运行索纳库贝...包装器-->包装器作为
问题内容: 我想知道,几秒钟后如何在jquery中隐藏div?例如Gmail的邮件。 我已经尽力了,但是无法正常工作。 问题答案: 这将在1秒(1000毫秒)后隐藏div。 如果您只想隐藏而不褪色,请使用。
由于连接到不同的API,我目前正在开发一个工具,允许我阅读所有的通知。 它工作得很好,但现在我想用一些声音命令来做一些动作。 就像当软件说“一封来自Bob的邮件”时,我想说“阅读”或“存档”。 我的软件是通过一个节点服务器运行的,目前我没有任何浏览器实现,但它可以是一个计划。 在NodeJS中,启用语音到文本的最佳方式是什么? 我在它上面看到了很多线程,但主要是使用浏览器,如果可能的话,我希望在一
语音识别是以语音为研究对象,通过语音信号处理和模式识别让机器自动识别和理解人类口述的语言。语音识别技术就是让机器通过识别和理解过程把语音信号转变为相应的文本或命令的高技术。语音识别是一门涉及面很广的交叉学科,它与声学、语音学、语言学、信息理论、模式识别理论以及神经生物学等学科都有非常密切的关系。语音识别技术正逐步成为计算机信息处理技术中的关键技术,语音技术的应用已经成为一个具有竞争性的新兴高技术产
识别简单的语句。
光环板内置的麦克风和Wi-Fi功能相结合,可以实现语音识别相关的应用。通过接入互联网,可以使用各大主流科技公司提供的语音识别服务,像是微软语音识别服务。使用联网功能需要登陆慧编程账号。 注册/登陆慧编程 点击工具栏右侧的登陆/注册按钮,依据提示登陆/注册账号。 启用上传模式 点击启用上传模式。 新建语音识别项目 我们将新建一个语音识别项目,使用语音来点亮光环板的LED灯。 连接网络 1. 添加事件