def updateDataWithNames()

in data_preparation/metadata_completion/ReaderScapper.py [0:0]


def updateDataWithNames(speakerData, idMatch):

    newData = deepcopy(speakerData)

    if speakerData["readers"] is None:
        newData["readers_names"] = None
        return newData

    newData["readers_names"] = []

    for item in speakerData["readers"]:
        if item is not None:
            for ID in item:
                if ID not in idMatch:
                    try:
                        idMatch[ID] = get_librivox_reader_from_id(ID)
                    except RuntimeError:
                        idMatch[ID] = None

    for item in speakerData["readers"]:
        if item is None:
            newData["readers_names"].append(None)
        else:
            all_names = []
            for ID in item:
                all_names.append(idMatch[ID])
            newData["readers_names"].append(all_names)

    return newData