opentts-uk / examples /count_duration.py
Yehor Smoliakov
Sync
b396397
raw
history blame
512 Bytes
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/accept'
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))