|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"""TODO: Add a description here.""" |
|
|
|
|
|
import csv |
|
import json |
|
import os |
|
|
|
import datasets |
|
|
|
|
|
_CITATION = """\ |
|
@misc{cooper2021generalization, |
|
title={Generalization Ability of MOS Prediction Networks}, |
|
author={Erica Cooper and Wen-Chin Huang and Tomoki Toda and Junichi Yamagishi}, |
|
year={2021}, |
|
eprint={2110.02635}, |
|
archivePrefix={arXiv}, |
|
primaryClass={eess.AS} |
|
} |
|
""" |
|
|
|
|
|
|
|
_DESCRIPTION = """\ |
|
This dataset is for internal use only. For voicemos challenge |
|
""" |
|
|
|
|
|
_HOMEPAGE = "https://codalab.lisn.upsaclay.fr/competitions/695" |
|
|
|
|
|
_LICENSE = "INTERNAL" |
|
|
|
|
|
class BvccDataset(datasets.GeneratorBasedBuilder): |
|
"""BVCC dataset for voicemos challenge 2022""" |
|
|
|
VERSION = datasets.Version("1.1.0") |
|
|
|
BUILDER_CONFIGS = [ |
|
datasets.BuilderConfig(name="main_track", version=VERSION, description="main track dataset by wavfiles"), |
|
datasets.BuilderConfig(name="main_track_listeners", version=VERSION, description="main track dataset by listener rating"), |
|
datasets.BuilderConfig(name="ood_track", version=VERSION, description="Out of domain dataset"), |
|
datasets.BuilderConfig(name="ood_track_unlabeled", version=VERSION, description="Out of domain dataset unlabeled"), |
|
datasets.BuilderConfig(name="ood_track_listeners", version=VERSION, description="ood track dataset by listener rating"), |
|
] |
|
|
|
DEFAULT_CONFIG_NAME = "main_track" |
|
|
|
def _info(self): |
|
|
|
if self.config.name == "main_track": |
|
features = datasets.Features( |
|
{ |
|
"path": datasets.Value("string"), |
|
"audio" : datasets.Audio(sampling_rate=16_000), |
|
"sysID": datasets.Value("string"), |
|
"uttID": datasets.Value("string"), |
|
"averaged rating": datasets.Value("float32"), |
|
|
|
} |
|
) |
|
elif self.config.name == "main_track_listeners": |
|
|
|
|
|
features = datasets.Features( |
|
{ |
|
"path": datasets.Value("string"), |
|
"audio" : datasets.Audio(sampling_rate=16_000), |
|
"sysID": datasets.Value("string"), |
|
"uttID": datasets.Value("string"), |
|
"rating": datasets.Value("int8"), |
|
"age range": datasets.Value("string"), |
|
"listener id": datasets.Value("string"), |
|
"gender": datasets.Value("string"), |
|
"hearing impairment": datasets.Value("string"), |
|
} |
|
) |
|
elif self.config.name == "ood_track": |
|
features = datasets.Features( |
|
{ |
|
"path": datasets.Value("string"), |
|
"audio" : datasets.Audio(sampling_rate=16_000), |
|
"sysID": datasets.Value("string"), |
|
"uttID": datasets.Value("string"), |
|
"averaged rating": datasets.Value("float32"), |
|
|
|
} |
|
) |
|
elif self.config.name == "ood_track_listeners": |
|
|
|
|
|
features = datasets.Features( |
|
{ |
|
"path": datasets.Value("string"), |
|
"audio" : datasets.Audio(sampling_rate=16_000), |
|
"sysID": datasets.Value("string"), |
|
"uttID": datasets.Value("string"), |
|
"rating": datasets.Value("int8"), |
|
"age range": datasets.Value("string"), |
|
"listener id": datasets.Value("string"), |
|
"gender": datasets.Value("string"), |
|
"hearing impairment": datasets.Value("string"), |
|
} |
|
) |
|
elif self.config.name == "ood_track_unlabeled": |
|
|
|
|
|
features = datasets.Features( |
|
{ |
|
"path": datasets.Value("string"), |
|
"audio" : datasets.Audio(sampling_rate=16_000), |
|
"sysID": datasets.Value("string"), |
|
"uttID": datasets.Value("string"), |
|
} |
|
) |
|
else: |
|
raise ValueError(f"invalid config name {self.config.name}") |
|
return datasets.DatasetInfo( |
|
description=_DESCRIPTION, |
|
features=features, |
|
homepage=_HOMEPAGE, |
|
license=_LICENSE, |
|
citation=_CITATION, |
|
) |
|
|
|
def _split_generators(self, dl_manager): |
|
|
|
|
|
|
|
|
|
|
|
|
|
data_dir = self.config.data_dir |
|
if "listeners" in self.config.name: |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir,"DATA/sets/TRAINSET"), |
|
"split": "train", |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir,"DATA/sets/DEVSET"), |
|
"split": "dev", |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir,"DATA/sets/test.scp"), |
|
"split": "test", |
|
}, |
|
), |
|
] |
|
elif "unlabeled" in self.config.name: |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir,"DATA/sets/unlabeled_mos_list.txt"), |
|
"split": "train", |
|
}, |
|
), |
|
] |
|
else: |
|
return [ |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TRAIN, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir,"DATA/sets/train_mos_list.txt"), |
|
"split": "train", |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.VALIDATION, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir,"DATA/sets/val_mos_list.txt"), |
|
"split": "dev", |
|
}, |
|
), |
|
datasets.SplitGenerator( |
|
name=datasets.Split.TEST, |
|
|
|
gen_kwargs={ |
|
"filepath": os.path.join(data_dir,"DATA/sets/test.scp"), |
|
"split": "test", |
|
}, |
|
), |
|
] |
|
|
|
|
|
def _generate_examples(self, filepath, split): |
|
|
|
|
|
with open(filepath, encoding="utf-8") as f: |
|
for key, row in enumerate(f.readlines()): |
|
data = row.strip().split(',') |
|
if self.config.name == "main_track": |
|
sysID, uttID= data[0].split('-') |
|
uttID= uttID.replace('.wav', '') |
|
if len(data) > 1: |
|
score = data[1] |
|
else: |
|
score = 999 |
|
|
|
path = os.path.join(self.config.data_dir, "DATA/wav/", data[0]) |
|
yield key, { |
|
"path": path, |
|
"audio": path, |
|
"sysID": sysID, |
|
"uttID": uttID, |
|
"averaged rating": score, |
|
} |
|
elif self.config.name == "main_track_listeners": |
|
if len(data) > 1: |
|
rating = data[1] |
|
sysID, path, rating, _, listenerinfo = data |
|
_, age, listenrID, gender, _ , _, hearingImpairement= listenerinfo.split("_") |
|
else: |
|
sysID, uttID= data[0].split('-') |
|
uttID= uttID.replace('.wav', '') |
|
rating = 999 |
|
age= 999 |
|
listenrID = 999 |
|
gender = 999 |
|
path = data[0] |
|
uttID = path.split('-')[-1] |
|
uttID = uttID.replace(".wav", "") |
|
path = os.path.join(self.config.data_dir, "DATA/wav/", path) |
|
yield key, { |
|
"path": path, |
|
"audio": path, |
|
"sysID": sysID, |
|
"uttID": uttID, |
|
"rating": rating, |
|
"age range": age, |
|
"listener id": listenrID, |
|
"gender": gender, |
|
"hearing impairment": hearingImpairement, |
|
} |
|
if self.config.name == "ood_track": |
|
sysID, uttID= data[0].split('-') |
|
uttID= uttID.replace('.wav', '') |
|
if len(data) > 1: |
|
score = data[1] |
|
else: |
|
score = 999 |
|
|
|
path = os.path.join(self.config.data_dir, "DATA/wav/", data[0]) |
|
yield key, { |
|
"path": path, |
|
"audio": path, |
|
"sysID": sysID, |
|
"uttID": uttID, |
|
"averaged rating": score, |
|
} |
|
elif self.config.name == "ood_track_listeners": |
|
if len(data) > 1: |
|
rating = data[1] |
|
sysID, path, rating, _, listenerinfo = data |
|
_, age, listenrID, gender, _ , _, hearingImpairement= listenerinfo.split("_") |
|
else: |
|
sysID, uttID= data[0].split('-') |
|
uttID= uttID.replace('.wav', '') |
|
path = data[0] |
|
rating = 999 |
|
age= 999 |
|
listenrID = 999 |
|
gender = 999 |
|
uttID = path.split('-')[-1] |
|
uttID = uttID.replace(".wav", "") |
|
path = os.path.join(self.config.data_dir, "DATA/wav/", path) |
|
yield key, { |
|
"path": path, |
|
"audio": path, |
|
"sysID": sysID, |
|
"uttID": uttID, |
|
"rating": rating, |
|
"age range": age, |
|
"listener id": listenrID, |
|
"gender": gender, |
|
"hearing impairment": hearingImpairement, |
|
} |
|
if self.config.name == "ood_track_unlabeled": |
|
sysID, uttID= data[0].strip().split('-') |
|
uttID= uttID.replace('.wav', '') |
|
|
|
path = os.path.join(self.config.data_dir, "DATA/wav/", data[0].strip()) |
|
yield key, { |
|
"path": path, |
|
"audio": path, |
|
"sysID": sysID, |
|
"uttID": uttID, |
|
} |
|
|