How can I get timestamps when using KenLM with the model?
#32
by
Nguyen667201
- opened
First of all, thank you to the NeMo team for this SOTA model.
I would like to combine KenLM with parakeet-tdt-0.6b-c2. However, it seems that the model's inference output does not include timestamps. How can I obtain them?
This is my code:
import torch
from copy import deepcopy
from nemo.collections.asr.parts.submodules import tdt_beam_decoding
from nemo.collections.asr.parts.submodules.ctc_decoding import CTCDecoding
from nemo.collections.asr.parts.submodules.rnnt_decoding import RNNTBPEDecoding
import nemo.collections.asr as nemo_asr
asr_model = nemo_asr.models.ASRModel.from_pretrained(model_name="nvidia/parakeet-tdt-0.6b-v2")
decoding_cfg = deepcopy(asr_model.cfg.decoding)
decoding_cfg.preserve_alignments = False
decoding_cfg.compute_timestamps = False
decoding_cfg.confidence_cfg.preserve_word_confidence = False
decoding_cfg.confidence_cfg.preserve_token_confidence = False
decoding_cfg.confidence_cfg.preserve_frame_confidence = False
decoding_cfg.strategy = "beam"
decoding_cfg.beam.beam_size = 5
asr_model.change_decoding_strategy(decoding_cfg=decoding_cfg)
asr_model.decoding.kenlm_path = "parakeet-tdt-0.6b-v2/Model/Kenlm_model/ken_lm4gram.binary"
output = asr_model.transcribe(['2086-149220-0033.wav'], return_hypotheses=True)