EddyVerbruggen / nativescript-speech-recognition

:speech_balloon: Speech to text, using the awesome engines readily available on the device.
Other
90 stars 21 forks source link

Android: transcript.text might have an issue #1

Closed bradmartin closed 7 years ago

bradmartin commented 7 years ago

Working on a video with the plugin and ran on Android and kept getting undefined in the onResult callback in the startListening() method with transcript.text === undefined https://github.com/EddyVerbruggen/nativescript-speech-recognition/blob/master/speech-recognition.android.ts#L117

Running on Android 6.0.

Ended up changing it to the following just to get it working for now locally:

if (!transcripts.isEmpty()) {
       let x;
       for (var i = 0; i < transcripts.size(); i++) {
           var transcript = transcripts.get(i);
           x = transcripts.get(0);
      }
        options.onResult({
              text: x,
             finished: true
        });
}