NeMo icon indicating copy to clipboard operation
NeMo copied to clipboard

how get tiemstamps for parakeet-tdt-0.6b-v2 in buffered mode

Open prorid3r opened this issue 1 year ago • 8 comments

I try to adjust this example https://github.com/NVIDIA/NeMo/blob/main/examples/asr/asr_chunked_inference/rnnt/speech_to_text_streaming_infer_rnnt.py

to use parakeet-tdt-0.6b-v2 and make it output timestamps with no success. Is it possible?

If thats not an option - what is the best way to proccess large recordings with timestamps?

Currently in transcribe_utils we get timestamps as tensor in write_transcription(), when called from the example code.

prorid3r avatar Jun 23 '25 12:06 prorid3r

@artbataev can we add the support for new streaming method as the chunk is non overlapping

nithinraok avatar Jun 25 '25 17:06 nithinraok

I just ran into a similar issue. No timestamps when running parakeet-tdt-0.6b-v2 through speech_to_text_buffered_infer_rnnt.py. I wonder how to run parakeet-tdt-0.6b-v2 to process long audios with timestamps. Thanks a lot!

jingzhaoou avatar Jun 25 '25 23:06 jingzhaoou

Currently, there is a problem that timestamp calculation requires alignments, which consume an enormous amount of memory. There is an ongoing work with fixing this issue by @lilithgrigoryan in #13949 I created PR #14030 to support saving timestamps in streaming (on top of that PR), but it is only working with RNN-T models, not TDT. I will continue the investigation.

artbataev avatar Jun 26 '25 13:06 artbataev

I fixed the issue with TDT, now it should work with both RNN-T and TDT models.

It is in the PR #14030 in a temporary branch add_timestamps_to_streaming, commit 129112e4f9 (includes changes from #13949 ) Planning to merge it into main but only after #13949

I got similar output with the streaming and offline inference with timestamps=true. I also observed no quality degradation when using (left_context_secs=10, chunk_secs=10, right_context_secs=5) - useful if you need to process long files.

How to use

streaming:

 python examples/asr/asr_chunked_inference/rnnt/speech_to_text_streaming_infer_rnnt.py \
    pretrained_name="nvidia/parakeet-tdt-0.6b-v2" \
    audio_dir="<dir_with_audio>" \
    output_filename="decoded.jsonl" \
    right_context_secs=5 \
    chunk_secs=10 \
    left_context_secs=10 \
    batch_size=32 \
    timestamps=true

offline:

python examples/asr/transcribe_speech.py \
    pretrained_name="nvidia/parakeet-tdt-0.6b-v2" \
    audio_dir="<dir_with_audio>" \
    output_filename="decoded.jsonl" \
    batch_size=32 \
    timestamps=true

artbataev avatar Jun 26 '25 17:06 artbataev

@artbataev thanks a lot for the prompt fix! I just tested the offline flow in your branch. The timestamps are showing up!

jingzhaoou avatar Jun 26 '25 19:06 jingzhaoou

  • Approach 1: I used a 3300-second audio to test speech_to_text_streaming_infer_rnnt.py (with the above settings). It took 15.8 seconds to finish on my L4 GPU.

  • Approach 2: I enabled local attention like the following

    asr_model = nemo_asr.models.ASRModel.restore_from(model_path)
    asr_model.change_attention_model("rel_pos_local_attn", [128, 128])
    asr_model.change_subsampling_conv_chunking_factor(1)

and transcribed the whole audio directly

output = asr_model.transcribe(audio=[audio_file], timestamps=args.timestamps)

which finished in 7.7 seconds.

With Approach 1, the GPU usage was around 65% while with Approach 2, the GPU usage stayed at 100%. Note that I set asr_model.to(torch.bfloat16) for both approaches.

My questions are:

  • How much accuracy might be lost with local attention enabled?
  • with Approach 1, any parameters can I tune to improve the GPU usage?

I appreciate your help!

jingzhaoou avatar Jun 26 '25 23:06 jingzhaoou

thanks a lot!

prorid3r avatar Jul 01 '25 13:07 prorid3r

python examples/asr/transcribe_speech.py
pretrained_name="nvidia/parakeet-tdt-0.6b-v2"
audio_dir="<dir_with_audio>"
output_filename="decoded.jsonl"
batch_size=32
timestamps=true

is ok,but dont support long files it will outofmemory. how to use speech_to_text_buffered_infer_rnnt.py?

1091492188 avatar Jul 03 '25 02:07 1091492188