Latest in AI
ML Kit Speech Recognition: Fix File Input, Missing Results and Word Timing
Google's on-device speech APIs offer several input paths, and choosing the wrong mode can make a valid recording look like a model failure.
ML Kit's GenAI Speech Recognition API supports microphone input, recorded files and custom audio streams, but those paths do not behave identically. If a file produces no final result or word timing throws an exception, check the input mode and stream lifecycle before assuming the speech model is broken.
Google's AI Edge Gallery update shows the wider opportunity: a local voice interface built from separate recognition, language and speech-synthesis components. The developer announcement was published November 10 and republished on Hugging Face November 12. This is a troubleshooting guide to the documented API, not a claim that it launched today or that I have tested it on a phone.
Check availability before debugging the recording
The Android speech-recognition guide labels the API alpha. Its current dependency is com.google.mlkit:genai-speech-recognition:1.0.0-alpha2. The SDK's minimum API level is 26, but Basic recognition requires runtime API level 31 or later; Advanced recognition is limited to supported devices with the relevant on-device model.
Those are different gates. An application can compile and install without the desired recognition feature being ready. Check the recognizer's status, handle unavailable or downloading states, and complete any required model download before starting the audio experiment.
Make the distinction visible in your app. “Speech model unavailable” and “Could not understand this recording” point the user toward different actions. One concerns device capability or setup; the other concerns the input or recognition result. A single generic error hides information your support team needs.
Use the file path for a recorded file
AudioSource.fromFile() and fromUri() use one-shot recognition and decode common audio formats on-device. A raw file-descriptor path has stricter requirements: headerless 16-bit PCM, mono, at 16 kHz.
That difference is easy to miss when connecting an existing recorder. A WAV file is not merely raw PCM with a different extension. If you already have a normal supported recording file, start with the file or URI method instead of pushing its bytes into a custom raw stream.
For a diagnostic fixture, use a short recording you are authorized to process. Keep the original file unchanged and record which input method you selected. If you convert the format, change only that step before repeating the check. Re-recording, resampling and changing model mode together makes a successful result difficult to explain.
A one-shot stream needs an end
With a custom one-shot file descriptor, the API waits for end-of-file before delivering the final transcription. Close the writing end when the audio is complete. With streaming mode, feed audio at real-time pace rather than dumping the whole file into the buffer.
For 16 kHz, 16-bit mono audio, the arithmetic is 16,000 samples multiplied by two bytes, or roughly 32,000 bytes per second. That gives you a useful sanity check for a custom producer, not a latency guarantee for the recognizer.
Instrument the boundary between producer and recognizer. Record when writing starts, when the final bytes are sent and when the writer closes. If the audio producer never signals completion, tuning the model will not fix the missing final result.
Word timing is not supported on one-shot files
The documented word-timing option works with streaming sources. Enabling it on a one-shot file or URI source throws IllegalArgumentException. If you only need the completed transcript, leave timing disabled rather than treating that exception as an unsupported audio codec.
If synchronized captions are essential, design around a supported streaming input and test timing separately from transcript accuracy. A word can be recognized correctly while still appearing at an inconvenient moment in your interface.
Also distinguish provisional and final text in your UI. Streaming recognition can revise partial output. Do not append every partial fragment as if it were a new permanent sentence, and do not trigger consequential actions from an unfinished phrase.
Test the offline workflow, not just the recognizer
A local recognizer is only one component of an offline voice feature. The language model, speech synthesizer, required downloads and application network requests need separate review. Once setup is complete, test a full interaction without connectivity and inspect which parts actually continue working.
The practical advantage of a modular voice pipeline is that you can isolate failures. Check availability, audio ingestion, finalization and presentation in that order. Otherwise, a missing stream-close event can waste hours of model evaluation.
I’m Paras. I work at the intersection of AI, engineering and distribution.
I help technical teams explain developer workflows and product constraints through useful, specific technical content.