Skip to content

Instantly share code, notes, and snippets.

@fauxneticien
Created September 21, 2023 02:40
Show Gist options
  • Save fauxneticien/5c9b748c8bfff6c4f9ad5b2034a8d410 to your computer and use it in GitHub Desktop.
Save fauxneticien/5c9b748c8bfff6c4f9ad5b2034a8d410 to your computer and use it in GitHub Desktop.
benchmark-fastconformer.py
import torch
import torchaudio
fakewav_80mins = torch.rand(1, 16_000 * 60 * 80)
torchaudio.save("tmp/80mins.wav", fakewav_80mins, 16_000)
import nemo.collections.asr as nemo_asr
asr_model = nemo_asr.models.EncDecCTCModelBPE.from_pretrained(model_name="nvidia/stt_en_fastconformer_ctc_large")
asr_model.eval()
with torch.inference_mode():
transcriptions = asr_model.transcribe(['tmp/80mins.wav'])
# Change to LongFormer-style local attention
asr_model.change_attention_model(
self_attention_model="rel_pos_local_attn",
att_context_size=[128, 128]
)
with torch.inference_mode():
transcriptions = asr_model.transcribe(['tmp/80mins.wav'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment