import json import warnings warnings.filterwarnings('ignore') from os.path import exists import librosa from datasets import load_dataset ds = load_dataset("Yehor/tts-mykyta-uk", "tetiana") files_dir = '/home/yehor/ext-ml-disk/tts/tts-mykyta-uk/files/tetiana/dataset_tetiana' for row in ds['train']: filename = f'{files_dir}/{row["audio"]}' if not exists(filename): continue duration = librosa.get_duration(path=filename) row['duration'] = duration print(json.dumps(row))