Upload 9 files
Browse files- Partition_10_tsv/calibration/calibration.py +114 -0
- Partition_10_tsv/calibration/corpus/files/tars_calibration.paths +1 -0
- Partition_10_tsv/calibration/corpus/speech/calibration.tar.gz +3 -0
- Partition_10_tsv/fine_tune/corpus/files/tars_fine_tune.paths +1 -0
- Partition_10_tsv/fine_tune/corpus/speech/fine_tune.tar.gz +3 -0
- Partition_10_tsv/fine_tune/fine_tune.py +114 -0
- Partition_10_tsv/test/corpus/files/tars_test.paths +1 -0
- Partition_10_tsv/test/corpus/speech/test.tar.gz +3 -0
- Partition_10_tsv/test/test.py +114 -0
Partition_10_tsv/calibration/calibration.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from collections import defaultdict
|
2 |
+
import os
|
3 |
+
import json
|
4 |
+
import csv
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
_NAME="spanish_trans_uq"
|
9 |
+
_VERSION="1.0.0"
|
10 |
+
_AUDIO_EXTENSIONS=".wav"
|
11 |
+
|
12 |
+
_DESCRIPTION = """
|
13 |
+
A custom dataset to evaluate UQ methods
|
14 |
+
|
15 |
+
"""
|
16 |
+
|
17 |
+
_CITATION = """
|
18 |
+
TODO
|
19 |
+
"""
|
20 |
+
|
21 |
+
_HOMEPAGE = "todo"
|
22 |
+
|
23 |
+
_LICENSE = "CC-BY-SA-4.0, See https://creativecommons.org/licenses/by-sa/4.0/"
|
24 |
+
|
25 |
+
_BASE_DATA_DIR = "corpus/"
|
26 |
+
_METADATA_calibration = os.path.join(_BASE_DATA_DIR,"files", "metadata_calibration.tsv")
|
27 |
+
|
28 |
+
_TARS_calibration = os.path.join(_BASE_DATA_DIR,"files", "tars_calibration.paths")
|
29 |
+
|
30 |
+
class SpanishTransUQcalibrationConfig(datasets.BuilderConfig):
|
31 |
+
"""BuilderConfig for the Spanish Transcription Uncertainty Quantification Benchmark Dataset"""
|
32 |
+
|
33 |
+
def __init__(self, name, **kwargs):
|
34 |
+
name=_NAME
|
35 |
+
super().__init__(name=name, **kwargs)
|
36 |
+
|
37 |
+
class SpanishTransUQcalibrationConfig(datasets.GeneratorBasedBuilder):
|
38 |
+
"""for the Spanish Transcription Uncertainty Quantification Benchmark Dataset"""
|
39 |
+
|
40 |
+
VERSION = datasets.Version(_VERSION)
|
41 |
+
BUILDER_CONFIGS = [
|
42 |
+
SpanishTransUQcalibrationConfig(
|
43 |
+
name=_NAME,
|
44 |
+
version=datasets.Version(_VERSION),
|
45 |
+
)
|
46 |
+
]
|
47 |
+
|
48 |
+
def _info(self):
|
49 |
+
features = datasets.Features(
|
50 |
+
{
|
51 |
+
"audio_id": datasets.Value("string"),
|
52 |
+
"audio": datasets.Audio(sampling_rate=16000),
|
53 |
+
"normalized_text": datasets.Value("string"),
|
54 |
+
}
|
55 |
+
)
|
56 |
+
return datasets.DatasetInfo(
|
57 |
+
description=_DESCRIPTION,
|
58 |
+
features=features,
|
59 |
+
homepage=_HOMEPAGE,
|
60 |
+
license=_LICENSE,
|
61 |
+
citation=_CITATION,
|
62 |
+
)
|
63 |
+
|
64 |
+
def _split_generators(self, dl_manager):
|
65 |
+
|
66 |
+
metadata_calibration=dl_manager.download_and_extract(_METADATA_calibration)
|
67 |
+
|
68 |
+
tars_calibration=dl_manager.download_and_extract(_TARS_calibration)
|
69 |
+
|
70 |
+
hash_tar_files=defaultdict(dict)
|
71 |
+
|
72 |
+
with open(tars_calibration,'r') as f:
|
73 |
+
hash_tar_files['calibration']=[path.replace('\n','') for path in f]
|
74 |
+
|
75 |
+
hash_meta_paths={"calibration":metadata_calibration}
|
76 |
+
audio_paths = dl_manager.download(hash_tar_files)
|
77 |
+
|
78 |
+
splits=["calibration"]
|
79 |
+
local_extracted_audio_paths = (
|
80 |
+
dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
|
81 |
+
{
|
82 |
+
split:[None] * len(audio_paths[split]) for split in splits
|
83 |
+
}
|
84 |
+
)
|
85 |
+
|
86 |
+
return [
|
87 |
+
datasets.SplitGenerator(
|
88 |
+
name=datasets.Split.calibration,
|
89 |
+
gen_kwargs={
|
90 |
+
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["calibration"]],
|
91 |
+
"local_extracted_archives_paths": local_extracted_audio_paths["calibration"],
|
92 |
+
"metadata_paths": hash_meta_paths["calibration"],
|
93 |
+
}
|
94 |
+
),
|
95 |
+
]
|
96 |
+
|
97 |
+
def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
|
98 |
+
|
99 |
+
features = ["speaker_id","gender","duration","normalized_text"]
|
100 |
+
|
101 |
+
with open(metadata_paths) as f:
|
102 |
+
metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
|
103 |
+
|
104 |
+
for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
|
105 |
+
for audio_filename, audio_file in audio_archive:
|
106 |
+
#audio_id = audio_filename.split(os.sep)[-1].split(_AUDIO_EXTENSIONS)[0]
|
107 |
+
audio_id =os.path.splitext(os.path.basename(audio_filename))[0]
|
108 |
+
path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
|
109 |
+
|
110 |
+
yield audio_id, {
|
111 |
+
"audio_id": audio_id,
|
112 |
+
**{feature: metadata[audio_id][feature] for feature in features},
|
113 |
+
"audio": {"path": path, "bytes": audio_file.read()},
|
114 |
+
}
|
Partition_10_tsv/calibration/corpus/files/tars_calibration.paths
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
corpus/speech/calibration.tar.gz
|
Partition_10_tsv/calibration/corpus/speech/calibration.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2ed6d3fed72d1d9931eb0477120b82f891c693730296ced600c3bea16e737313
|
3 |
+
size 24737792
|
Partition_10_tsv/fine_tune/corpus/files/tars_fine_tune.paths
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
corpus/speech/fine_tune.tar.gz
|
Partition_10_tsv/fine_tune/corpus/speech/fine_tune.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c619a63a022b586bc9e172a8b1924e03b648941863b9e61a16d54de12e59b109
|
3 |
+
size 75936768
|
Partition_10_tsv/fine_tune/fine_tune.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from collections import defaultdict
|
2 |
+
import os
|
3 |
+
import json
|
4 |
+
import csv
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
_NAME="spanish_trans_uq"
|
9 |
+
_VERSION="1.0.0"
|
10 |
+
_AUDIO_EXTENSIONS=".wav"
|
11 |
+
|
12 |
+
_DESCRIPTION = """
|
13 |
+
A custom dataset to evaluate UQ methods
|
14 |
+
|
15 |
+
"""
|
16 |
+
|
17 |
+
_CITATION = """
|
18 |
+
TODO
|
19 |
+
"""
|
20 |
+
|
21 |
+
_HOMEPAGE = "todo"
|
22 |
+
|
23 |
+
_LICENSE = "CC-BY-SA-4.0, See https://creativecommons.org/licenses/by-sa/4.0/"
|
24 |
+
|
25 |
+
_BASE_DATA_DIR = "corpus/"
|
26 |
+
_METADATA_fine_tune = os.path.join(_BASE_DATA_DIR,"files", "metadata_fine_tune.tsv")
|
27 |
+
|
28 |
+
_TARS_fine_tune = os.path.join(_BASE_DATA_DIR,"files", "tars_fine_tune.paths")
|
29 |
+
|
30 |
+
class SpanishTransUQfine_tuneConfig(datasets.BuilderConfig):
|
31 |
+
"""BuilderConfig for the Spanish Transcription Uncertainty Quantification Benchmark Dataset"""
|
32 |
+
|
33 |
+
def __init__(self, name, **kwargs):
|
34 |
+
name=_NAME
|
35 |
+
super().__init__(name=name, **kwargs)
|
36 |
+
|
37 |
+
class SpanishTransUQfine_tuneConfig(datasets.GeneratorBasedBuilder):
|
38 |
+
"""for the Spanish Transcription Uncertainty Quantification Benchmark Dataset"""
|
39 |
+
|
40 |
+
VERSION = datasets.Version(_VERSION)
|
41 |
+
BUILDER_CONFIGS = [
|
42 |
+
SpanishTransUQfine_tuneConfig(
|
43 |
+
name=_NAME,
|
44 |
+
version=datasets.Version(_VERSION),
|
45 |
+
)
|
46 |
+
]
|
47 |
+
|
48 |
+
def _info(self):
|
49 |
+
features = datasets.Features(
|
50 |
+
{
|
51 |
+
"audio_id": datasets.Value("string"),
|
52 |
+
"audio": datasets.Audio(sampling_rate=16000),
|
53 |
+
"normalized_text": datasets.Value("string"),
|
54 |
+
}
|
55 |
+
)
|
56 |
+
return datasets.DatasetInfo(
|
57 |
+
description=_DESCRIPTION,
|
58 |
+
features=features,
|
59 |
+
homepage=_HOMEPAGE,
|
60 |
+
license=_LICENSE,
|
61 |
+
citation=_CITATION,
|
62 |
+
)
|
63 |
+
|
64 |
+
def _split_generators(self, dl_manager):
|
65 |
+
|
66 |
+
metadata_fine_tune=dl_manager.download_and_extract(_METADATA_fine_tune)
|
67 |
+
|
68 |
+
tars_fine_tune=dl_manager.download_and_extract(_TARS_fine_tune)
|
69 |
+
|
70 |
+
hash_tar_files=defaultdict(dict)
|
71 |
+
|
72 |
+
with open(tars_fine_tune,'r') as f:
|
73 |
+
hash_tar_files['fine_tune']=[path.replace('\n','') for path in f]
|
74 |
+
|
75 |
+
hash_meta_paths={"fine_tune":metadata_fine_tune}
|
76 |
+
audio_paths = dl_manager.download(hash_tar_files)
|
77 |
+
|
78 |
+
splits=["fine_tune"]
|
79 |
+
local_extracted_audio_paths = (
|
80 |
+
dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
|
81 |
+
{
|
82 |
+
split:[None] * len(audio_paths[split]) for split in splits
|
83 |
+
}
|
84 |
+
)
|
85 |
+
|
86 |
+
return [
|
87 |
+
datasets.SplitGenerator(
|
88 |
+
name=datasets.Split.fine_tune,
|
89 |
+
gen_kwargs={
|
90 |
+
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["fine_tune"]],
|
91 |
+
"local_extracted_archives_paths": local_extracted_audio_paths["fine_tune"],
|
92 |
+
"metadata_paths": hash_meta_paths["fine_tune"],
|
93 |
+
}
|
94 |
+
),
|
95 |
+
]
|
96 |
+
|
97 |
+
def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
|
98 |
+
|
99 |
+
features = ["speaker_id","gender","duration","normalized_text"]
|
100 |
+
|
101 |
+
with open(metadata_paths) as f:
|
102 |
+
metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
|
103 |
+
|
104 |
+
for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
|
105 |
+
for audio_filename, audio_file in audio_archive:
|
106 |
+
#audio_id = audio_filename.split(os.sep)[-1].split(_AUDIO_EXTENSIONS)[0]
|
107 |
+
audio_id =os.path.splitext(os.path.basename(audio_filename))[0]
|
108 |
+
path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
|
109 |
+
|
110 |
+
yield audio_id, {
|
111 |
+
"audio_id": audio_id,
|
112 |
+
**{feature: metadata[audio_id][feature] for feature in features},
|
113 |
+
"audio": {"path": path, "bytes": audio_file.read()},
|
114 |
+
}
|
Partition_10_tsv/test/corpus/files/tars_test.paths
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
corpus/speech/test.tar.gz
|
Partition_10_tsv/test/corpus/speech/test.tar.gz
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9359ae6ab67a9b12f7de9961ea178d294deacfd8ed03a695c91a06fd0a8ad261
|
3 |
+
size 26424832
|
Partition_10_tsv/test/test.py
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from collections import defaultdict
|
2 |
+
import os
|
3 |
+
import json
|
4 |
+
import csv
|
5 |
+
|
6 |
+
import datasets
|
7 |
+
|
8 |
+
_NAME="spanish_trans_uq"
|
9 |
+
_VERSION="1.0.0"
|
10 |
+
_AUDIO_EXTENSIONS=".wav"
|
11 |
+
|
12 |
+
_DESCRIPTION = """
|
13 |
+
A custom dataset to evaluate UQ methods
|
14 |
+
|
15 |
+
"""
|
16 |
+
|
17 |
+
_CITATION = """
|
18 |
+
TODO
|
19 |
+
"""
|
20 |
+
|
21 |
+
_HOMEPAGE = "todo"
|
22 |
+
|
23 |
+
_LICENSE = "CC-BY-SA-4.0, See https://creativecommons.org/licenses/by-sa/4.0/"
|
24 |
+
|
25 |
+
_BASE_DATA_DIR = "corpus/"
|
26 |
+
_METADATA_TEST = os.path.join(_BASE_DATA_DIR,"files", "metadata_test.tsv")
|
27 |
+
|
28 |
+
_TARS_TEST = os.path.join(_BASE_DATA_DIR,"files", "tars_test.paths")
|
29 |
+
|
30 |
+
class SpanishTransUQTestConfig(datasets.BuilderConfig):
|
31 |
+
"""BuilderConfig for the Spanish Transcription Uncertainty Quantification Benchmark Dataset"""
|
32 |
+
|
33 |
+
def __init__(self, name, **kwargs):
|
34 |
+
name=_NAME
|
35 |
+
super().__init__(name=name, **kwargs)
|
36 |
+
|
37 |
+
class SpanishTransUQTestConfig(datasets.GeneratorBasedBuilder):
|
38 |
+
"""for the Spanish Transcription Uncertainty Quantification Benchmark Dataset"""
|
39 |
+
|
40 |
+
VERSION = datasets.Version(_VERSION)
|
41 |
+
BUILDER_CONFIGS = [
|
42 |
+
SpanishTransUQTestConfig(
|
43 |
+
name=_NAME,
|
44 |
+
version=datasets.Version(_VERSION),
|
45 |
+
)
|
46 |
+
]
|
47 |
+
|
48 |
+
def _info(self):
|
49 |
+
features = datasets.Features(
|
50 |
+
{
|
51 |
+
"audio_id": datasets.Value("string"),
|
52 |
+
"audio": datasets.Audio(sampling_rate=16000),
|
53 |
+
"normalized_text": datasets.Value("string"),
|
54 |
+
}
|
55 |
+
)
|
56 |
+
return datasets.DatasetInfo(
|
57 |
+
description=_DESCRIPTION,
|
58 |
+
features=features,
|
59 |
+
homepage=_HOMEPAGE,
|
60 |
+
license=_LICENSE,
|
61 |
+
citation=_CITATION,
|
62 |
+
)
|
63 |
+
|
64 |
+
def _split_generators(self, dl_manager):
|
65 |
+
|
66 |
+
metadata_test=dl_manager.download_and_extract(_METADATA_TEST)
|
67 |
+
|
68 |
+
tars_test=dl_manager.download_and_extract(_TARS_TEST)
|
69 |
+
|
70 |
+
hash_tar_files=defaultdict(dict)
|
71 |
+
|
72 |
+
with open(tars_test,'r') as f:
|
73 |
+
hash_tar_files['test']=[path.replace('\n','') for path in f]
|
74 |
+
|
75 |
+
hash_meta_paths={"test":metadata_test}
|
76 |
+
audio_paths = dl_manager.download(hash_tar_files)
|
77 |
+
|
78 |
+
splits=["test"]
|
79 |
+
local_extracted_audio_paths = (
|
80 |
+
dl_manager.extract(audio_paths) if not dl_manager.is_streaming else
|
81 |
+
{
|
82 |
+
split:[None] * len(audio_paths[split]) for split in splits
|
83 |
+
}
|
84 |
+
)
|
85 |
+
|
86 |
+
return [
|
87 |
+
datasets.SplitGenerator(
|
88 |
+
name=datasets.Split.TEST,
|
89 |
+
gen_kwargs={
|
90 |
+
"audio_archives": [dl_manager.iter_archive(archive) for archive in audio_paths["test"]],
|
91 |
+
"local_extracted_archives_paths": local_extracted_audio_paths["test"],
|
92 |
+
"metadata_paths": hash_meta_paths["test"],
|
93 |
+
}
|
94 |
+
),
|
95 |
+
]
|
96 |
+
|
97 |
+
def _generate_examples(self, audio_archives, local_extracted_archives_paths, metadata_paths):
|
98 |
+
|
99 |
+
features = ["speaker_id","gender","duration","normalized_text"]
|
100 |
+
|
101 |
+
with open(metadata_paths) as f:
|
102 |
+
metadata = {x["audio_id"]: x for x in csv.DictReader(f, delimiter="\t")}
|
103 |
+
|
104 |
+
for audio_archive, local_extracted_archive_path in zip(audio_archives, local_extracted_archives_paths):
|
105 |
+
for audio_filename, audio_file in audio_archive:
|
106 |
+
#audio_id = audio_filename.split(os.sep)[-1].split(_AUDIO_EXTENSIONS)[0]
|
107 |
+
audio_id =os.path.splitext(os.path.basename(audio_filename))[0]
|
108 |
+
path = os.path.join(local_extracted_archive_path, audio_filename) if local_extracted_archive_path else audio_filename
|
109 |
+
|
110 |
+
yield audio_id, {
|
111 |
+
"audio_id": audio_id,
|
112 |
+
**{feature: metadata[audio_id][feature] for feature in features},
|
113 |
+
"audio": {"path": path, "bytes": audio_file.read()},
|
114 |
+
}
|