audio icon indicating copy to clipboard operation
audio copied to clipboard

Scripting compatibility for torchaudio.compliance.kaldi.fbank

Open thisiskofi opened this issue 3 years ago • 1 comments

Hi, I'm seeing some issues when I try to include torchaudio.compliance.kaldi.fbank preprocessing in my torchscript model:

RuntimeError:
python value of type 'float' cannot be used as a value. Perhaps it is a closed over global variable? If so, please consider passing it in as an argument or use a local varible instead.:
  File "/home/kboakye/miniconda3/envs/audio/lib/python3.8/site-packages/torchaudio/compliance/kaldi.py", line 138
    assert channel < waveform.size(0), "Invalid channel {} for size {}".format(channel, waveform.size(0))
    waveform = waveform[channel, :]  # size (n)
    window_shift = int(sample_frequency * frame_shift * MILLISECONDS_TO_SECONDS)
                                                        ~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    window_size = int(sample_frequency * frame_length * MILLISECONDS_TO_SECONDS)

Fixing this issue by substituting the value reveals still more issues in the scripting process. Is scripting possible with this function?

thisiskofi avatar Jun 03 '22 21:06 thisiskofi

Hi @thisiskofi

Thanks for the report, torchaudio.compliance.kaldi is from pre-TorchScript era, so they do not support TorchScript. I am working to add a new version of Kaldi features. I'll post update when it's ready.

mthrok avatar Jun 06 '22 17:06 mthrok