我在连续使用 VR 时遇到问题。在我的代码中有一个实现 VR 的片段。
它有效,但有时我看到它没有任何明显的原因就停止了。没有错误,没有崩溃,我可以通过点击两次按钮重新启动。
日志没有帮助,这就是我通过 LogCat 得到的
08-27 23:46:00.708 I/AudioService(433): AudioFocus requestAudioFocus() from android.media.AudioManager@422819d8com.google.android.voicesearch.audio.AudioRouterImpl$1@4229e1a8
08-27 23:46:00.755 I/VS.G3EngineManager(15890): create_rm: m=ENDPOINTER_DICTATION,l=en-US
08-27 23:46:00.770 I/VS.G3EngineManager(15890): Brought up new g3 instance :/system/usr/srec/en-US/endpointer_dictation.config for: en-USin: 13 ms
08-27 23:46:00.848 W/Sidekick_LocationOracleImpl(15890): Best location was null
08-27 23:46:00.856 W/Sidekick_LocationOracleImpl(15890): Best location was null
08-27 23:46:01.505 I/ActivityManager(433): Start proc com.devexpert.weather for broadcast com.devexpert.weather/.view.WidgetWeather2x1: pid=16138 uid=10071 gids={50071, 3003, 1015, 1028}
08-27 23:46:01.911 W/RecognitionDispatcher(15890): Could not stop engine 3
08-27 23:46:06.356 I/MicrophoneInputStream(15890): mic_close
08-27 23:46:06.388 I/AudioService(433): AudioFocus abandonAudioFocus() from android.media.AudioManager@422819d8com.google.android.voicesearch.audio.AudioRouterImpl$1@4229e1a8
08-27 23:46:06.411 I/decoder (15890): INFO: recognition time wall: 5.61636 sec user: 1.49219 sec sys: 0.234375 sec
08-27 23:46:06.544 I/GoogleRecognitionServiceImpl(15890): #startListening [it-IT]
08-27 23:46:06.552 I/AudioService(433): AudioFocus requestAudioFocus() from android.media.AudioManager@422819d8com.google.android.voicesearch.audio.AudioRouterImpl$1@4229e1a8
08-27 23:46:06.552 I/VS.G3EngineManager(15890): create_rm: m=ENDPOINTER_DICTATION,l=en-US
08-27 23:46:06.575 I/VS.G3EngineManager(15890): Brought up new g3 instance :/system/usr/srec/en-US/endpointer_dictation.config for: en-USin: 25 ms
08-27 23:46:06.598 W/Sidekick_LocationOracleImpl(15890): Best location was null
08-27 23:46:06.606 W/Sidekick_LocationOracleImpl(15890): Best location was null
08-27 23:46:07.661 W/RecognitionDispatcher(15890): Could not stop engine 3
08-27 23:46:11.231 I/MicrophoneInputStream(15890): mic_close
08-27 23:46:11.263 I/AudioService(433): AudioFocus abandonAudioFocus() from android.media.AudioManager@422819d8com.google.android.voicesearch.audio.AudioRouterImpl$1@4229e1a8
08-27 23:46:11.278 I/decoder (15890): INFO: recognition time wall: 4.67749 sec user: 1.21875 sec sys: 0.21875 sec
08-27 23:46:11.395 I/GoogleRecognitionServiceImpl(15890): #startListening [it-IT]
08-27 23:46:11.411 I/AudioService(433): AudioFocus requestAudioFocus() from android.media.AudioManager@422819d8com.google.android.voicesearch.audio.AudioRouterImpl$1@4229e1a8
08-27 23:46:11.419 I/VS.G3EngineManager(15890): create_rm: m=ENDPOINTER_DICTATION,l=en-US
08-27 23:46:11.450 I/VS.G3EngineManager(15890): Brought up new g3 instance :/system/usr/srec/en-US/endpointer_dictation.config for: en-USin: 28 ms
08-27 23:46:11.450 W/Search.ConcurrentUtils(15890): Executor queue length is now 2. Perhaps some tasks are too long, or the pool is too small. [GrecoExecutor-1]
08-27 23:46:11.450 I/AudioService(433): AudioFocus abandonAudioFocus() from android.media.AudioManager@422819d8com.google.android.voicesearch.audio.AudioRouterImpl$1@4229e1a8
08-27 23:46:11.458 W/Sidekick_LocationOracleImpl(15890): Best location was null
08-27 23:46:11.458 W/Sidekick_LocationOracleImpl(15890): Best location was null
08-27 23:46:11.489 W/PairHttpConnection(15890): [Upload] Connection error
08-27 23:46:11.489 W/PairHttpConnection(15890): java.io.IOException: Timed out / error during connect
08-27 23:46:11.489 W/PairHttpConnection(15890): at com.google.android.speech.network.PairHttpConnection.connect(PairHttpConnection.java:135)
08-27 23:46:11.489 W/PairHttpConnection(15890): at com.google.android.speech.network.NetworkRecognitionRunner.runNetworkLoop(NetworkRecognitionRunner.java:219)
08-27 23:46:11.489 W/PairHttpConnection(15890): at com.google.android.speech.network.NetworkRecognitionRunner.access$000(NetworkRecognitionRunner.java:54)
08-27 23:46:11.489 W/PairHttpConnection(15890): at com.google.android.speech.network.NetworkRecognitionRunner$1.run(NetworkRecognitionRunner.java:73)
08-27 23:46:11.489 W/PairHttpConnection(15890): at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
08-27 23:46:11.489 W/PairHttpConnection(15890): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
08-27 23:46:11.489 W/PairHttpConnection(15890): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:153)
08-27 23:46:11.489 W/PairHttpConnection(15890): at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:267)
08-27 23:46:11.489 W/PairHttpConnection(15890): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
08-27 23:46:11.489 W/PairHttpConnection(15890): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
08-27 23:46:11.489 W/PairHttpConnection(15890): at com.google.android.searchcommon.util.ConcurrentUtils$1$1.run(ConcurrentUtils.java:90)
如您所见,VR 有 3 个开始,最后一个循环由于 IOEXCEPTION 而停止
我们从这个 github 获得了源代码https://github.com/fcrisciani/android-speech-recognition/tree/master/VoiceRecognition/src/com/speech/fcrisciani/voicerecognition