Get features from given input wav using preprocessor of an asr model. 
State: closed | Pull request: no
Labels: name: bug

**Describe the bug**

For inference, i would like to try the feature extractor part individually using [.get_features()](https://github.com/NVIDIA/NeMo/blob/65bcb68640469d1c77d7882520511546e67fc514/nemo/collections/asr/modules/audio_preprocessing.py) function that's already implemented. As i understood, the inputs for this function are input_signal and the length. But, when i give the inputs, i get an error as i explained in below. I want to know if this method can be work. 

**Steps/Code to reproduce bug**

0. Setup your environment. 
 - nemo installation (commit - cd6a691607894f13cafcbe7994d1b2809ccb7aa4)

pip3 install git+https://github.com/NVIDIA/NeMo.git@cd6a691607894f13cafcbe7994d1b2809ccb7aa4
pip3 install torch==1.7.1 torchaudio==0.7.2 

1. Download the STT En Jasper10x5dr (.nemo) model.
```
wget --content-disposition https://api.ngc.nvidia.com/v2/models/nvidia/nemo/stt_en_jasper10x5dr/versions/1.0.0rc1/zip -O stt_en_jasper10x5dr_1.0.0rc1.zip
```

2. Extract the file into your workspace.
```
unzip stt_en_jasper10x5dr_1.0.0rc1.zip
```

3. Import the nemo asr models.
```
import nemo.collections.asr as nemo_asr
```

4. Restore the model 
```
asr_model = nemo_asr.models.EncDecCTCModel.restore_from('stt_en_jasper10x5dr.nemo')
```

5. Import torch and torchaudio 

```
import torch
import torchaudio
```
6. Download the test file (.wav)

```
SAMPLE_WAV_SPEECH_PATH = '1919-142785-0028.wav'
!wget https://dldata-public.s3.us-east-2.amazonaws.com/1919-142785-0028.wav
device = 'gpu'
```

7. Get input signal and the length out from the wav file 

```
waveform, sample_rate = torchaudio.load(SAMPLE_WAV_SPEECH_PATH)

# cpu tensor into device (gpu)
waveform = waveform.to(torch.device('cuda'))

# generate the length as tensor
si, ei = torchaudio.info(SAMPLE_WAV_SPEECH_PATH)
length = si.length
length = torch.cuda.IntTensor(length)
```

7. Call get_features() function 
```

with torch.no_grad():
    
    feature = self.asr_model.preprocessor.get_features(input_signal=waveform,length=length).to(device).eval()
```


**Expected behavior**

It gives me an error saying CUDA out of memory. 
```
Traceback (most recent call last):
  File "/jasper/triton/triton_client.py", line 351, in <module>
    STTInferClass_th.infer(filenames)
  File "/jasper/triton/triton_client.py", line 314, in infer
    self.get_features_nemo(filenames)
  File "/jasper/triton/triton_client.py", line 305, in get_features_nemo
    feature = self.asr_model.preprocessor.get_features(input_signal=waveform,length=y).to(device).eval()
  File "/usr/local/lib/python3.8/dist-packages/nemo/collections/asr/modules/audio_preprocessing.py", line 259, in get_features
    return self.featurizer(input_signal, length)
  File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/torch/autograd/grad_mode.py", line 26, in decorate_context
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/nemo/collections/asr/parts/preprocessing/features.py", line 422, in forward
    x = x.masked_fill(mask.unsqueeze(1).type(torch.bool).to(device=x.device), self.pad_value)
RuntimeError: CUDA out of memory. Tried to allocate 5.59 GiB (GPU 0; 14.76 GiB total capacity; 5.69 GiB already allocated; 1.28 GiB free; 11.28 GiB reserved in total by PyTorch)
```

**nvidia-smi**

![Screenshot from 2021-09-08 14-45-26](https://user-images.githubusercontent.com/15320876/132468074-c1bcf62c-2643-451e-a369-a7ecc7a2588d.png)


**Environment overview (please complete the following information)**

 - Environment location: [Cloud(AWS), EC2 T4 Instance]
 - Method of NeMo install: [pip3 install git+https://github.com/NVIDIA/NeMo.git@cd6a691607894f13cafcbe7994d1b2809ccb7aa4]. .

**Environment details**

- OS version - Ubuntu 20.04
- PyTorch version - 1.7.1
- Python version - 3.8

Thank you,