Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonVoice, missing extension when loading an audio clip #1125

Closed
jeremyfix opened this issue Dec 24, 2020 · 2 comments · Fixed by #1126
Closed

CommonVoice, missing extension when loading an audio clip #1125

jeremyfix opened this issue Dec 24, 2020 · 2 comments · Fixed by #1126

Comments

@jeremyfix
Copy link

jeremyfix commented Dec 24, 2020

🐛 Bug

When accessing the first element of the commonvoice dataset, it fails with :

  File "test_data.py", line 17, in test001
    waveform, sample_rate, dictionnary = train_dataset[0]
  File "/home/fix_jer/.local/lib/python3.6/site-packages/torchaudio/datasets/commonvoice.py", line 233, in __getitem__
    return load_commonvoice_item(line, self._header, self._path, self._folder_audio)
  File "/home/fix_jer/.local/lib/python3.6/site-packages/torchaudio/datasets/commonvoice.py", line 96, in load_commonvoice_item
    waveform, sample_rate = torchaudio.load(filename)
  File "/home/fix_jer/.local/lib/python3.6/site-packages/torchaudio/backend/sox_backend.py", line 35, in load
    raise OSError("{} not found or is a directory".format(filepath))
OSError: /opt/Datasets/CommonVoice/fr_79h_2019-02-25/fr/clips/89e67e7682b36786a0b4b4022c4d42090c86edd96c78c12d30088e62522b8fe466ea4912e6a1055dfb91b296a0743e0a2bbe16cebac98ee5349e3e8262cb9329 not found or is a directory

Indead, the clip exists, but it seams to me the extension ".mp3" is missing. The filename provided to "torchaudio.load" does not contain the extension since the train.tsv file does not contain the extension.

One workaround is to edit commonvoice.py:L93, and changing :

filename = os.path.join(path, folder_audio, fileid+'.mp3')

To Reproduce

Steps to reproduce the behavior:

_COMMONVOICE_ROOT="/opt/Datasets/"
_COMMONVOICE_VERSION="fr_79h_2019-02-25"
dataset =COMMONVOICE(root=_COMMONVOICE_ROOT,
                                           version=_COMMONVOICE_VERSION,
                                           url='french')

waveform, sample_rate, dictionnary = dataset[0]
print(dictionnary)

Expected behavior

After adding the ".mp3" extension in commonvoice.py , I get the expected behavior :

Loading /opt/Datasets/CommonVoice/fr_79h_2019-02-25/fr/clips/89e67e7682b36786a0b4b4022c4d42090c86edd96c78c12d30088e62522b8fe466ea4912e6a1055dfb91b296a0743e0a2bbe16cebac98ee5349e3e8262cb9329.mp3
{'client_id': 'a2e8e1e1cc74d08c92a53d7b9ff84e077eb90410edd85b8882f16fd037cecfcb6a19413c6c63ce6458cfea9579878fa91cef18343441c601cae0597a4b0d3144', 'path': '89e67e7682b36786a0b4b4022c4d42090c86edd96c78c12d30088e62522b8fe466ea4912e6a1055dfb91b296a0743e0a2bbe16cebac98ee5349e3e8262cb9329', 'sentence': 'Or sur ce point nous n’avons aucune réponse de votre part.', 'up_votes': '2', 'down_votes': '0', 'age': 'twenties', 'gender': 'male', 'accent': 'france'}

Environment

  • What commands did you used to install torchaudio (conda/pip/build from source)? pip
  • If you are building from source, which commit is it?
  • What does torchaudio.__version__ print? (If applicable) 0.7.2

Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).

You can get the script and run it with:

wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py

PyTorch version: 1.7.1
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 18.04.5 LTS (x86_64)
GCC version: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Clang version: 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
CMake version: version 3.10.2

Python version: 3.6 (64-bit runtime)
Is CUDA available: False
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] botorch==0.1.4
[pip3] gpytorch==1.0.1
[pip3] numpy==1.17.4
[pip3] numpy-stl==1.6.2
[pip3] pytorch-complex==0.0.8
[pip3] torch==1.7.1
[pip3] torchaudio==0.7.2
[pip3] torchdiffeq==0.0.1
[pip3] torchtext==0.8.0
[pip3] torchvision==0.8.1+cpu
[conda] Could not collect

@AzizCode92
Copy link
Contributor

Hi @jeremyfix, I have created a PR #1126 in response to your issue.
Could you please try my fix locally and tell me if it solves your issue?
thanks

@jeremyfix
Copy link
Author

Hi @AzizCode92 , thanks for opening a PR, I tested and replied directly in the PR #1126

@mthrok mthrok linked a pull request Dec 24, 2020 that will close this issue
mthrok pushed a commit that referenced this issue Dec 27, 2020
Resolves #1125 where dataset metadata does not contain an extension.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants