facebookresearch / libri-light

dataset for lightly supervised training using the librivox audio book recordings. https://librivox.org/.
MIT License
480 stars 78 forks source link

Wrong version of torchaudio #50

Closed jmosinski closed 1 year ago

jmosinski commented 1 year ago

Hi, when running build_all_stats.py, there is the following error: TypeError: 'AudioMetaData' object is not subscriptable. Torchaudio changed this object, so you should either apply try, except to handle this difference or use older version of torchaudio in your environment.yaml. Here is the code to fix this issue without using older torchaudioversion: Add the below funcion in the libri-light/data_preparation/metadata_completion/utils.py and use it in parts of code when you use torch.info().

def get_audio_size(path_audio_data):
    try:
        info = torchaudio.info(path_audio_data)[0]
        length = info.length
        rate = info.rate
    except:
        info = torchaudio.info(str(path_audio_data))
        length = info.num_frames
        rate = info.sample_rate
    return length / (rate * 3600.)
jacobkahn commented 1 year ago

Fix has been merged.