facebookresearch / encodec

State-of-the-art deep learning based audio codec supporting both mono 24 kHz audio and stereo 48 kHz audio.
MIT License
3.48k stars 304 forks source link

Invalid file: WindowsPath of encodec using Windows OS. #13

Closed MartinEesmaa closed 1 year ago

MartinEesmaa commented 1 year ago

🐛 Bug Report

When I tried to encode from WAV to ECDC file, python gave me an error for invalid file using Windows OS. On Linux, works well, but only Windows OS did not work.

To Reproduce

  1. Install encodec using pip install .
  2. Install pysoundfile using pip
  3. Encode from uncompressed WAV to encodec (.ecdc)

Expected behavior

Encode success from WAV to ECDC.

Actual Behavior

Saying invalid file for trying find WAV file

Your Environment

The error code is for Windows OS only:

encodec -b 24 -r MSESTONIA.wav MSESTONIA.ecdc
Traceback (most recent call last):
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\Scripts\encodec.exe\__main__.py", line 7, in <module>
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\__main__.py", line 109, in main
    wav, sr = torchaudio.load(args.input)
  File "C:\Users\marti\AppData\Roaming\Python\Python310\site-packages\torchaudio\backend\soundfile_backend.py", line 205, in load
    with soundfile.SoundFile(filepath, "r") as file_:
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\soundfile.py", line 740, in __init__
    self._file = self._open(file, mode_int, closefd)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\soundfile.py", line 1263, in _open
    raise TypeError("Invalid file: {0!r}".format(self.name))
TypeError: Invalid file: WindowsPath('MSESTONIA.wav')
Limeysoda1 commented 1 year ago

I think I solved this by 'pip install librosa'

MartinEesmaa commented 1 year ago

Thanks @Limeysoda1, but I got a different error. I think maybe issue for PyTorch:

Traceback (most recent call last):
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\Scripts\encodec.exe\__main__.py", line 7, in <module>
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\__main__.py", line 111, in main
    compressed = compress(model, wav, use_lm=args.lm)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\compress.py", line 172, in compress
    compress_to_file(model, wav, fo, use_lm=use_lm)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\compress.py", line 51, in compress_to_file
    frames = model.encode(wav[None])
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\model.py", line 144, in encode
    encoded_frames.append(self._encode_frame(frame))
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\model.py", line 161, in _encode_frame
    emb = self.encoder(x)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\modules\seanet.py", line 144, in forward
    return self.model(x)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\container.py", line 204, in forward
    input = module(input)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\modules\seanet.py", line 63, in forward
    return self.shortcut(x) + self.block(x)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\modules\conv.py", line 210, in forward
    return self.conv(x)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1190, in _call_impl
    return forward_call(*input, **kwargs)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\encodec\modules\conv.py", line 120, in forward
    x = self.conv(x)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1208, in _call_impl
    result = forward_call(*input, **kwargs)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\conv.py", line 313, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "C:\Users\marti\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\conv.py", line 309, in _conv_forward
    return F.conv1d(input, weight, bias, self.stride,
RuntimeError: could not create a primitive

Torch versions:

torch                     1.13.0+cu117
torchaudio                0.13.0+cu117
adefossez commented 1 year ago

It is possible that your CPU doesn't support some of the instruction sets required by PyTorch. You should open an issue with PyTorch as this is not really related to the our code.

MartinEesmaa commented 1 year ago

Oh, I see, thank you. I will submit the issue in PyTorch and this repository will be closed my issue by myself.