"""Create a JSON file mapping of available audio files to the TTS models that generated them. The output JSON has the following structure: { "path1.mp3": [ "model1", "model2", ... ], "path2.mp3": [ "model1", ... ], ... } """ from collections import defaultdict import json import os import pandas as pd df = pd.read_csv("metadata-balanced.csv") models = ["commonvoice", "metavoice", "playht", "stylettsv2", "xttsv2"] ds = defaultdict(list) for path in df.path: for model in models: if os.path.exists(os.path.join(model, path)): ds[path].append(model) with open("files.json", "w") as json_file: json.dump(ds, json_file, indent=4)