Update model.py to fix "IndexError: index 1 is out of bounds for dimension 1 with size 0" (#2454)
* Update model.py
Avoid exception of "IndexError: index 1 is out of bounds for dimension 1 with size 0"
* Update model.py
Add return word in timestamps
* Revert "Update model.py"
This reverts commit bc736df30282e004b9b4b572e5f943cddf63eac0.
| | |
| | | if tok_ls: token_ids.extend(tok_ls) |
| | | else: token_ids.append(124) |
| | | |
| | | if len(token_ids) == 0: |
| | | result_i = {"key": key[i], "text": text} |
| | | results.append(result_i) |
| | | continue |
| | | |
| | | logits_speech = self.ctc.softmax(encoder_out)[i, 4 : encoder_out_lens[i].item(), :] |
| | | pred = logits_speech.argmax(-1).cpu() |
| | | logits_speech[pred == self.blank_id, self.blank_id] = 0 |