fix(asr): do not call InputFinished for a never-ending stream
A live caption stream never ends: the boundary of an utterance is silence, not end-of-input, so InputFinished (which means "no more audio ever") does not apply. Drop it and rely on the trailing audio alone; keep a short silence padding as a safety net for end-of-file cases. Verified that the file path still emits the final character without InputFinished. 实时字幕的音频流永不结束,一句话的边界是"静音"而不是"输入结束",所以 不该调用语义为"再也不会有音频"的 InputFinished。改为只补一小段静音兜底, 实测文件模式的结果依然完整。文档也一并更正。
This commit is contained in:
1 parent
bd921b1ac5
commit
b37b9eb779
2 files changed
+9
-4
No files matched your search
@@ -92,9 +92,10 @@ std::string SherpaAsr::streamFinish()
|
||||
const std::vector<float> silence(pad, 0.0f);
|
||||
SherpaOnnxOnlineStreamAcceptWaveform(d->stream, 16000, silence.data(), (int32_t) pad);
|
||||
d->drain();
|
||||
// 通知不再有输入,把尾部一并解出来
|
||||
SherpaOnnxOnlineStreamInputFinished(d->stream);
|
||||
d->drain();
|
||||
// 注意:这里**不调用 InputFinished**。
|
||||
// 实时字幕的音频流是永不结束的,一句话的边界是"静音"而不是"输入结束";
|
||||
// InputFinished 的语义(再也不会有音频了)对文件才成立,对我们不适用。
|
||||
// 只需要补一小段静音,让模型把最后一个字吐出来即可。
|
||||
return d->resultText();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user