Error occurred when I tried to import torchaudio

I installed torchaudio according to the instruction by https://github.com/pytorch/audio. Nevertheless, when I tried to import torchaudio, the following error message popped up:

Traceback (most recent call last):
File “test.py”, line 1, in
import torchaudio
File “/Users/q7/Desktop/Wavenet/audio-master/torchaudio/init.py”, line 7, in
from torchaudio import transforms, datasets, kaldi_io, sox_effects, legacy, compliance
File “/Users/q7/Desktop/Wavenet/audio-master/torchaudio/transforms.py”, line 6, in
from . import functional as F
File “/Users/q7/Desktop/Wavenet/audio-master/torchaudio/functional.py”, line 108, in
@torch.jit.script
File “/anaconda3/lib/python3.7/site-packages/torch/jit/init.py”, line 824, in script
fn = torch._C._jit_script_compile(ast, _rcb, get_default_args(obj))
File “/anaconda3/lib/python3.7/site-packages/torch/jit/annotations.py”, line 55, in get_signature
return parse_type_line(type_line)
File “/anaconda3/lib/python3.7/site-packages/torch/jit/annotations.py”, line 97, in parse_type_line
raise RuntimeError(“Failed to parse the argument list of a type annotation: {}”.format(str(e)))
RuntimeError: Failed to parse the argument list of a type annotation: name ‘Optional’ is not defined

Can someone propose a solution? Thanks a lot.

I am having the same problem. Using torch 1.1.0.

1 Like

There was bad commit in torchaudio. Solution: old version with pytorch 1.0.
pip3 install git+https://github.com/pytorch/audio@d92de5b

Any other alternative?
This fails on current version
transform = torchaudio.transforms.DownmixMono(channels_first=True)
__init__() got an unexpected keyword argument 'channels_first'

The __init__ method just contains a pass statement.