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 filling of waveform_buffer with samples for streaming inference #5267

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 10 additions & 11 deletions espnet2/bin/asr_inference_streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,19 +222,18 @@ def apply_frontend(
speech_to_process = speech
waveform_buffer = None
else:
n_frames = (
speech.size(0) - (self.win_length - self.hop_length)
) // self.hop_length
n_residual = (
speech.size(0) - (self.win_length - self.hop_length)
) % self.hop_length
speech_to_process = speech.narrow(
0, 0, (self.win_length - self.hop_length) + n_frames * self.hop_length
)
n_frames = speech.size(0) // self.hop_length
n_residual = speech.size(0) % self.hop_length
speech_to_process = speech.narrow(0, 0, n_frames * self.hop_length)
waveform_buffer = speech.narrow(
0,
speech.size(0) - (self.win_length - self.hop_length) - n_residual,
(self.win_length - self.hop_length) + n_residual,
speech.size(0)
- (math.ceil(math.ceil(self.win_length / self.hop_length) / 2) * 2 - 1)
* self.hop_length
- n_residual,
(math.ceil(math.ceil(self.win_length / self.hop_length) / 2) * 2 - 1)
* self.hop_length
+ n_residual,
).clone()

# data: (Nsamples,) -> (1, Nsamples)
Expand Down