Class SpeechRecognizer

java.lang.Object
com.codename1.media.SpeechRecognizer

public final class SpeechRecognizer extends Object

On-device speech-to-text.

  • iOS -- backed by SFSpeechRecognizer. The first call prompts the user for microphone + speech-recognition permission (the latter requires NSSpeechRecognitionUsageDescription in Info.plist, which the build server injects automatically when this class is referenced).
  • Android -- backed by android.speech.SpeechRecognizer. May use Google's cloud speech endpoint on older devices; on Pixel and modern flagships it runs fully on-device.
  • JavaSE simulator -- no built-in implementation. Add cn1-ai-whisper to enable on-device transcription via whisper.cpp, or expect isSupported() to return false.
if (SpeechRecognizer.isSupported()) {
    SpeechRecognizer.recognizeOnce(new RecognitionCallback.Adapter() {
        public void onResult(String t, float c, String[] a) {
            form.findTextField().setText(t);
        }
    });
}