Use torchaudio cause torch jit load model error,help!

we use pytorch version of 1.7.0+cu101 to turn torchscript,and I successfully loaded the torchscript model in torch version of 1.7.0+cu101 to inference, but when I use pytorch version of 1.8.1+cu101 to inference, there are some error

python3 torch_test_jit_1109.py 
Traceback (most recent call last): File "torch_test_jit_1109.py", line 35, in <module> main(sys.argv[1], sys.argv[2]) File "torch_test_jit_1109.py", line 17, in main e2e_model = torch.jit.load(script_model) File "/data3/users/suziyi/Miniconda3/lib/python3.8/site-packages/torch/jit/_serialization.py", line 161, in load cpp_module = torch._C.import_ir_module(cu, str(f), map_location, _extra_files) RuntimeError: Class Namespace cannot be used as a value: Serialized File "code/__torch__/torchaudio/sox_effects/sox_effects.py", line 5 effects: List[List[str]], channels_first: bool=True) -> Tuple[Tensor, int]: in_signal = __torch__.torch.classes.torchaudio.TensorSignal.__new__(__torch__.torch.classes.torchaudio.TensorSignal) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE _0 = (in_signal).__init__(tensor, sample_rate, channels_first, ) out_signal = ops.torchaudio.sox_effects_apply_effects_tensor(in_signal, effects) 'apply_effects_tensor' is being compiled since it was called from 'SynthesizerTrn.forward' Serialized File "code/__torch__/models_torchaudio_torchscript.py", line 41 sr: Tensor, vol: Tensor) -> Tensor: _0 = __torch__.torchaudio.sox_effects.sox_effects.apply_effects_tensor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE _1 = torch.tensor([(torch.size(x))[-1]], dtype=None, device=None, requires_grad=False) x_lengths = torch.to(_1, 4, False, False, None)

we use torchaudio to change audio speed,volume and so on, please help me
when we create torchscript the pytorch version is 1.7.0+cu101 , the torchaudio version is 0.7.0

Hi @c9412600, thanks for sharing the issue. Could you share your script that uses sox_effect?
Also you can post it on torchaudio’s GitHub page. This helps other people who also meet this problem.

Thanks for your reply,that’s my script ,please check

import torch
import torchaudio.sox_effects as sox_effects

 def forward(self, audio: torch.Tensor, speed: torch.Tensor, pitch: torch.Tensor, sr: torch.Tensor, vol: torch.Tensor): 

    speed = str(speed.item())

    pitch = str(pitch.item())

    sr = str(int(sr.item()))

    vol = str(vol.item())

    effects = [['tempo','-s', speed], ['pitch', pitch],['rate', sr], ['vol', vol]]

    waveform, _ = sox_effects.apply_effects_tensor(audio, int(sr), effects)

    return waveform