You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have found out that timeout in continuous mode is not stopping utt. Is this a bug?
Made some changes in SpeechRecognizer.java to get it stopped (see "//UN" comments):
@Override
public void run() {
recorder.startRecording();
if (recorder.getRecordingState() == AudioRecord.RECORDSTATE_STOPPED) {
recorder.stop();
IOException ioe = new IOException(
"Failed to start recording. Microphone might be already in use.");
mainHandler.post(new OnErrorEvent(ioe));
return;
}
Log.d(TAG, "Starting decoding");
decoder.startUtt();
short[] buffer = new short[bufferSize];
boolean inSpeech = decoder.getInSpeech();
// Skip the first buffer, usually zeroes
recorder.read(buffer, 0, buffer.length);
//UN moved from while loop
if (inSpeech)
remainingSamples = timeoutSamples;
//UN end
while (!interrupted()
&& ((timeoutSamples == NO_TIMEOUT) || (remainingSamples > 0))) {
int nread = recorder.read(buffer, 0, buffer.length);
if (-1 == nread) {
throw new RuntimeException("error reading audio buffer");
} else if (nread > 0) {
decoder.processRaw(buffer, nread, false, false);
// int max = 0;
// for (int i = 0; i < nread; i++) {
// max = Math.max(max, Math.abs(buffer[i]));
// }
// Log.e("!!!!!!!!", "Level: " + max);
if (decoder.getInSpeech() != inSpeech) {
inSpeech = decoder.getInSpeech();
mainHandler.post(new InSpeechChangeEvent(inSpeech));
}
//UN moved this out of while loop
//UN if (inSpeech)
//UN remainingSamples = timeoutSamples;
final Hypothesis hypothesis = decoder.hyp();
mainHandler.post(new ResultEvent(hypothesis, false));
}
if (timeoutSamples != NO_TIMEOUT) {
remainingSamples = remainingSamples - nread;
}
}
recorder.stop();
decoder.endUtt();
// Remove all pending notifications.
mainHandler.removeCallbacksAndMessages(null);
// If we met timeout signal that speech ended
if (timeoutSamples != NO_TIMEOUT && remainingSamples <= 0) {
mainHandler.post(new TimeoutEvent());
}
}
}
The text was updated successfully, but these errors were encountered:
I have found out that timeout in continuous mode is not stopping utt. Is this a bug?
Made some changes in SpeechRecognizer.java to get it stopped (see "//UN" comments):
The text was updated successfully, but these errors were encountered: