k2-fsa / sherpa

Speech-to-text server framework with next-gen Kaldi
https://k2-fsa.github.io/sherpa
Apache License 2.0
483 stars 97 forks source link

is_final is False when endpoint detected #436

Closed chiiyeh closed 4 months ago

chiiyeh commented 12 months ago

When endpoint is detected the segment breaks as expected but the is_final remains as False. Took a look at the code, seems like the is_final variable does not get updated to True when is_endpoint is True. Not sure if this is the intended behavior.

https://github.com/k2-fsa/sherpa/blob/3d4a3321a8acfa276e6179a4c9aa81f12607996f/sherpa/cpp_api/online-recognizer.cc#L426-L432

pkufool commented 12 months ago

I think is_final means we reach the end of the audio, and is_endpoint means we need to break the audio at this point, when is_endpoint is true, we can continue decoding, but when is_final is true, the decoding is done. @csukuangfj might have more to say.

I think is_endpoint here is more like vad.

chiiyeh commented 12 months ago

Ah, actually i realize is more of needing the json return final to be True when endpoint is detected to match what is stated here: https://k2-fsa.github.io/sherpa/python/streaming_asr/endpointing.html#endpointing Where the message['final']=True when endpoint is detected.

Right now it appears that it is just taking the is_final value. So when endpoint is detected the message['final'] returns a False instead. https://github.com/k2-fsa/sherpa/blob/3d4a3321a8acfa276e6179a4c9aa81f12607996f/sherpa/cpp_api/online-recognizer.cc#L52

KazBrekker1 commented 10 months ago

I'm facing the same issue

currently I set the last prediction of each segment as the final, not sure if this is equivalent to the expected case or not.

csukuangfj commented 9 months ago

@chiiyeh https://github.com/k2-fsa/sherpa-onnx/pull/342

Please have a look at the above pull-request.

We will fix the implementation in k2-fsa/sherpa

mmulesa commented 6 months ago

when use use_endpoint=True , just change in online-recognizer.cc

if (is_endpoint || is_final) {
  decoder_->FinalizeResult(s, &r);
}

to

if (is_endpoint || is_final) {
  is_final = true;
  decoder_->FinalizeResult(s, &r);
}
KazBrekker1 commented 5 months ago

Any news for this issue?