Skip to content

Commit 798e323

Browse files
committed
Fix decoder call in Device ASR tutorial
1 parent 47eaab4 commit 798e323

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

examples/tutorials/device_asr.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,16 +206,15 @@ def __init__(self, bundle: torchaudio.pipelines.RNNTBundle, beam_width: int = 10
206206
self.beam_width = beam_width
207207

208208
self.state = None
209-
self.hypothesis = None
209+
self.hypotheses = None
210210

211211
def infer(self, segment: torch.Tensor) -> str:
212212
"""Perform streaming inference"""
213213
features, length = self.feature_extractor(segment)
214-
hypos, self.state = self.decoder.infer(
215-
features, length, self.beam_width, state=self.state, hypothesis=self.hypothesis
214+
self.hypotheses, self.state = self.decoder.infer(
215+
features, length, self.beam_width, state=self.state, hypothesis=self.hypotheses
216216
)
217-
self.hypothesis = hypos[0]
218-
transcript = self.token_processor(self.hypothesis[0], lstrip=False)
217+
transcript = self.token_processor(self.hypotheses[0][0], lstrip=False)
219218
return transcript
220219

221220

@@ -291,7 +290,7 @@ def infer():
291290
chunk = q.get()
292291
segment = cacher(chunk[:, 0])
293292
transcript = pipeline.infer(segment)
294-
print(transcript, end="", flush=True)
293+
print(transcript, end="\r", flush=True)
295294

296295
import torch.multiprocessing as mp
297296

0 commit comments

Comments
 (0)