Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return condition and add resize code in online-audio-source.cc #4047

Merged
merged 2 commits into from
Apr 21, 2020
Merged

Fix return condition and add resize code in online-audio-source.cc #4047

merged 2 commits into from
Apr 21, 2020

Conversation

KimJeongSun
Copy link
Contributor

i used this source for online-audio-client. but when i process last frame of audio.
that frame is skipped because of this condition.
i think it's because pos_ == src_.Dim() at last frame.
so i changed condition of return. and add resize code for last frame.
it works well in my environment.
I would appreciate it if you review.

@@ -177,12 +177,14 @@ bool OnlineVectorSource::Read(Vector<BaseFloat> *data) {
if (data->Dim() == subsrc.Dim()) {
data->CopyFromVec(subsrc);
} else {
data->Resize(n_elem);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nshmyrev @hhadian can you guys please check this? I'm suspicious because it looks to me like whoever wrote this code intended that data should not be resized. Incidentally, in this kind of situation you should pass in a pointer to SubVector, not Vector. (However, I do think this code has another issue, which is that it fails to zero the unset part of *data.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi

I have checked the issue. The only place where it is used is OnlineFeatureInput and data->Resize is not harmful there. Moreover, some implementations like GstOnlineSource already resize. TcpInputSource don't resize.

Logically I'd better resize than add zero.

So I would:

  1. Keep this change as is
  2. Add a note on the method documentation comment that the data can be resized.
  3. Fix TcpInputSource too.

@danpovey
Copy link
Contributor

danpovey commented Apr 20, 2020 via email

@KimJeongSun
Copy link
Contributor Author

I added same code in online-tcp-source.cc.
Please check when you have time.
Thank you for review.

@danpovey danpovey merged commit 3b4d044 into kaldi-asr:master Apr 21, 2020
pc-seawind pushed a commit to pc-seawind/kaldi that referenced this pull request Jun 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants