Search code examples
androidspeech-recognitionoptimus

TTS text received & processed but NOT HEARD on LG Optimus S


On one hand, this problem is tough because I have the same exact code working perfectly on 3 different Android 2.2 phones, but not working on an LG Optimus S (runing Android 2.2, too).

On the other hand, this problem is reproducible, so there may be some hope on the way to solving the mystery.

The problem manifests itself such that the first two text segments passed to the TTS engine (Pico) are processed (and heard through the speaker!) correctly on all phones, including the problematic one (LG Optimus S).

But the third and fourth segments passed to the TTS engine, after the speech RecognitionController's RECOGNIZED step, results in totally benign logs in all phones, except that in the problematic phone nothing is heard through the speaker! - despite receiving all OnUtteranceCompleted() even for the problematic phone!

I know the code is correct because it works perfectly on all other phones, so I am stumped as to what could be causing this.

Could this be inadequate CPU resources? inadequate memory resources?

If so, why does it work for the first 2 text segments, but doesn't work for successive 2 text segments?

If that could help in spotting something "weird" in the system behavior, I am including a sample logcat of the missing TTS-speech on the problematic phone:

INFO/RecognitionController(1773): State change: RECOGNIZING -> RECOGNIZED
INFO/RecognitionController(1773): Final state: RECOGNIZED
INFO/ServerConnectorImpl(1773): ClientReport{session_id=040af29064d281350f1325c6a361f003,request_id=1,application_id=voice-search,client_perceived_request_status=0,request_ack_latency_ms=93,total_latency_ms=2179,user_perceived_latency_ms=213,network_type=1,endpoint_trigger_type=3,}
INFO/AudioService(121):  AudioFocus  abandonAudioFocus() from android.media.AudioManager@45a4f450
DEBUG/AppRecognizer(2167): Proceed.
INFO/TTS received:(2167): Speaking text segment number three but NOTHING is coming out of the speaker!!! 
VERBOSE/TtsService(572): TTS service received Speaking text segment number three but NOTHING is coming out of the speaker!!! 
VERBOSE/TtsService(572): TTS processing: Speaking text segment number three but NOTHING is coming out of the speaker!!! 
VERBOSE/TtsService(572): TtsService.setLanguage(eng, USA, )
INFO/SVOX Pico Engine(572): Language already loaded (en-US == en-US)
INFO/SynthProxy(572): setting speech rate to 100
INFO/SynthProxy(572): setting pitch to 100
INFO/ClientReportSender(1773): Sending 1 client reports over HTTP
INFO/TTS received:(2167): Speaking text segment number four but NOTHING is coming out of the speaker!!!
VERBOSE/TtsService(572): TTS service received Speaking text segment number four but NOTHING is coming out of the speaker!!!
WARN/AudioTrack(572): obtainBuffer timed out (is the CPU pegged?) 0x5b3988 user=00062b40, server=00061b40
VERBOSE/TtsService(572): TTS callback: dispatch started
VERBOSE/TtsService(572): TTS callback: dispatch completed to 1
VERBOSE/TtsService(572): TTS processing: Speaking text segment number four but NOTHING is coming out of the speaker!!!
VERBOSE/onUtteranceCompleted(2167): segment #3
VERBOSE/TtsService(572): TtsService.setLanguage(eng, USA, )
INFO/SVOX Pico Engine(572): Language already loaded (en-US == en-US)
INFO/SynthProxy(572): setting speech rate to 100
INFO/SynthProxy(572): setting pitch to 100
WARN/AudioTrack(572): obtainBuffer timed out (is the CPU pegged?) 0x5b3988 user=0007dc00, server=0007cc00
VERBOSE/TtsService(572): TTS callback: dispatch started
VERBOSE/TtsService(572): TTS callback: dispatch completed to 1
VERBOSE/onUtteranceCompleted(2167): segment #4

The corresponding log on a phone that works perfectly looks like this:

INFO/RecognitionController(1773): State change: RECOGNIZING -> RECOGNIZED
INFO/RecognitionController(1773): Final state: RECOGNIZED
INFO/ServerConnectorImpl(1773): ClientReport{session_id=040af29064d281350f1325c6a361f003,request_id=1,application_id=voice-search,client_perceived_request_status=0,request_ack_latency_ms=96,total_latency_ms=2449,user_perceived_latency_ms=140,network_type=1,endpoint_trigger_type=3,}
INFO/AudioService(121):  AudioFocus  abandonAudioFocus() from android.media.AudioManager@46039d08
DEBUG/AppRecognizer(2167): Proceed.
INFO/TTS received:(2167): Speaking text segment number three (and I can hear it :) 
VERBOSE/TtsService(572): TTS service received Speaking text segment number three (and I can hear it :) 
VERBOSE/TtsService(572): TTS processing: Speaking text segment number three (and I can hear it :) 
INFO/ClientReportSender(1773): Sending 1 client reports over HTTP
VERBOSE/TtsService(572): TtsService.setLanguage(eng, USA, )
INFO/SVOX Pico Engine(572): TtsEngine::setLanguage found matching language(eng) but not matching country().
INFO/SVOX Pico Engine(572): Language already loaded (en-US == en-US)
INFO/SynthProxy(572): setting speech rate to 100
INFO/SynthProxy(572): setting pitch to 100
INFO/TTS received:(2167): Speaking text segment number four (and I can hear it :)
VERBOSE/TtsService(572): TTS service received Speaking text segment number four (and I can hear it :)
INFO/AudioHardwareQSD(121): AudioHardware pcm playback is going to standby.
DEBUG/dalvikvm(3262): GC_EXPLICIT freed 6946 objects / 326312 bytes in 76ms
WARN/AudioTrack(572): obtainBuffer timed out (is the CPU pegged?) 0x3ce730 user=00032e80, server=00031e80
WARN/AudioFlinger(121): write blocked for 170 msecs, 161 delayed writes, thread 0xdc08
VERBOSE/TtsService(572): TTS callback: dispatch started
VERBOSE/onUtteranceCompleted(2167): segment #3
VERBOSE/TtsService(572): TTS callback: dispatch completed to 1
VERBOSE/TtsService(572): TTS processing: Speaking text segment number four (and I can hear it :)
VERBOSE/TtsService(572): TtsService.setLanguage(eng, USA, )
INFO/SVOX Pico Engine(572): TtsEngine::setLanguage found matching language(eng) but not matching country().
INFO/SVOX Pico Engine(572): Language already loaded (en-US == en-US)
INFO/SynthProxy(572): setting speech rate to 100
INFO/SynthProxy(572): setting pitch to 100
WARN/KeyCharacterMap(2167): No keyboard for id 131074
WARN/KeyCharacterMap(2167): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
DEBUG/dalvikvm(7137): GC_EXPLICIT freed 1585 objects / 93216 bytes in 67ms
DEBUG/dalvikvm(6697): GC_EXPLICIT freed 3108 objects / 178688 bytes in 59ms
VERBOSE/TtsService(572): TTS callback: dispatch started
VERBOSE/onUtteranceCompleted(2167): segment #4

UPDATE I: The problem (only in the LG Optimus S LS670) only occurs after the speech recognizer kicks in for the first time. I can send any number of text segments, some of which are very long, and the TTS engine speaks out loud perfectly. But the moment the phone goes into listening (not at the same time as speaking, of course), TTS stops sounding out loud. As if some speaker "mute" occurs automatically as soon as speech recognizer kicks in but not restored automatically, once speech recognition is done.

I actually went ahead and tried inserting an audioManager.setMicrophoneMute(false); in RecognitionListener.onEndOfSpeech() but that didn't help.

UPDATE II: I even tried adding to RecognitionListener.onEndOfSpeech() the following, thinking that prehaps restarting the TTS engine could reset a bug somwhere - this didn't help either:

Intent checkIntent = new Intent();
checkIntent.setAction(TextToSpeech.Engine.ACTION_CHECK_TTS_DATA);
startActivityForResult(checkIntent, TTS_STATCHECK);    

Ideas? Suggestions?


Solution

  • Problem solved by simply accepting the OTA firmware update from Android 2.2.2 (Froyo) to Android 2.3.3 (Gingerbread).

    It turns out that this was a bug in the OS, in that particular ROM (LS670ZVD), not in my code.