Skip to content

Commit ae7aff2

Browse files
authored
fix: solve problems in sensevoice_bin.py related to argmax and unique, as mentioned in issue #2331 (#2332)
1 parent 2e0b208 commit ae7aff2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

runtime/python/onnxruntime/funasr_onnx/sensevoice_bin.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,10 @@ def __call__(self, wav_content: Union[str, np.ndarray, List[str]], **kwargs):
183183
# ctc_logits = torch.from_numpy(ctc_logits).float()
184184
# support batch_size=1 only currently
185185
x = ctc_logits[b, : encoder_out_lens[b].item(), :]
186-
yseq = x.argmax(dim=-1)
187-
yseq = np.unique(yseq)
186+
yseq = np.argmax(x, axis=-1)
187+
# Use np.diff and np.where instead of torch.unique_consecutive.
188+
mask = np.concatenate(([True], np.diff(yseq) != 0))
189+
yseq = yseq[mask]
188190

189191
mask = yseq != self.blank_id
190192
token_int = yseq[mask].tolist()

0 commit comments

Comments
 (0)