-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Conversation
@@ -177,12 +177,14 @@ bool OnlineVectorSource::Read(Vector<BaseFloat> *data) { | |||
if (data->Dim() == subsrc.Dim()) { | |||
data->CopyFromVec(subsrc); | |||
} else { | |||
data->Resize(n_elem); |
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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:
- Keep this change as is
- Add a note on the method documentation comment that the data can be resized.
- Fix TcpInputSource too.
Thanks. Jeong-Sun, can you please fix TcpInputSource too?
…On Tue, Apr 21, 2020 at 12:08 AM Nickolay V. Shmyrev < ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/online/online-audio-source.cc
<#4047 (comment)>:
> @@ -177,12 +177,14 @@ bool OnlineVectorSource::Read(Vector<BaseFloat> *data) {
if (data->Dim() == subsrc.Dim()) {
data->CopyFromVec(subsrc);
} else {
+ data->Resize(n_elem);
Hi
I have checked the issue. The only place where it is used is
OnlineFeatureInput
<https://github.com/kaldi-asr/kaldi/blob/5968b4cc03f9deccfd566962d3bba96bad8ce522/src/online/online-feat-input.h#L325>
and data->Resize is not harmful there. Moreover, some implementations like
GstOnlineSource already resize
<https://github.com/kaldi-asr/kaldi/blob/5968b4cc03f9deccfd566962d3bba96bad8ce522/src/gst-plugin/gst-audio-source.cc#L110>.
TcpInputSource don't resize
<https://github.com/kaldi-asr/kaldi/blob/5968b4cc03f9deccfd566962d3bba96bad8ce522/src/online/online-tcp-source.cc#L143>
.
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.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4047 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAZFLO6OJQUDALTURW4EQZDRNRXPXANCNFSM4MMGCHEQ>
.
|
I added same code in |
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.