Upload sesge.py
Browse files
sesge.py
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import csv
|
2 |
+
import os
|
3 |
+
import json
|
4 |
+
|
5 |
+
import datasets
|
6 |
+
from datasets.utils.py_utils import size_str
|
7 |
+
from tqdm import tqdm
|
8 |
+
|
9 |
+
from scipy.io.wavfile import read, write
|
10 |
+
import io
|
11 |
+
|
12 |
+
#from .release_stats import STATS
|
13 |
+
|
14 |
+
_CITATION = """\
|
15 |
+
@inproceedings{demint2024,
|
16 |
+
author = {Pérez-Ortiz, Juan Antonio and
|
17 |
+
Esplà-Gomis, Miquel and
|
18 |
+
Sánchez-Cartagena, Víctor M. and
|
19 |
+
Sánchez-Martínez, Felipe and
|
20 |
+
Chernysh, Roman and
|
21 |
+
Mora-Rodríguez, Gabriel and
|
22 |
+
Berezhnoy, Lev},
|
23 |
+
title = {{DeMINT}: Automated Language Debriefing for English Learners via {AI}
|
24 |
+
Chatbot Analysis of Meeting Transcripts},
|
25 |
+
booktitle = {Proceedings of the 13th Workshop on NLP for Computer Assisted Language Learning},
|
26 |
+
month = october,
|
27 |
+
year = {2024},
|
28 |
+
url = {https://aclanthology.org/volumes/2024.nlp4call-1/},
|
29 |
+
}
|
30 |
+
"""
|
31 |
+
|
32 |
+
class SesgeConfig(datasets.BuilderConfig):
|
33 |
+
def __init__(self, name, version, **kwargs):
|
34 |
+
self.language = kwargs.pop("language", None)
|
35 |
+
self.release_date = kwargs.pop("release_date", None)
|
36 |
+
description = (
|
37 |
+
"A dataset containing English speech with grammatical errors, along with the corresponding transcriptions."
|
38 |
+
"Utterances are synthesized using a text-to-speech model, whereas the grammatically incorrect texts come from the C4_200M synthetic dataset."
|
39 |
+
)
|
40 |
+
|
41 |
+
super(SesgeConfig, self).__init__(
|
42 |
+
name=name,
|
43 |
+
**kwargs,
|
44 |
+
)
|
45 |
+
|
46 |
+
class Sesge():
|
47 |
+
|
48 |
+
BUILDER_CONFIGS = [
|
49 |
+
SesgeConfig(
|
50 |
+
name="sesge",
|
51 |
+
version=1.0,
|
52 |
+
language='eng',
|
53 |
+
release_date="2024-10-8",
|
54 |
+
)
|
55 |
+
]
|
56 |
+
|
57 |
+
def _info(self):
|
58 |
+
total_languages = 1
|
59 |
+
total_valid_hours = 1
|
60 |
+
description = (
|
61 |
+
"A dataset containing English speech with grammatical errors, along with the corresponding transcriptions."
|
62 |
+
"Utterances are synthesized using a text-to-speech model, whereas the grammatically incorrect texts come from the C4_200M synthetic dataset."
|
63 |
+
)
|
64 |
+
features = datasets.Features(
|
65 |
+
{
|
66 |
+
"audio": datasets.features.Audio(sampling_rate=48_000),
|
67 |
+
"sentence": datasets.Value("string"),
|
68 |
+
}
|
69 |
+
)
|
70 |
+
|
71 |
+
def _generate_examples(self, local_extracted_archive_paths, archives, meta_path, split):
|
72 |
+
archives = os.listdir(archives)
|
73 |
+
metadata = {}
|
74 |
+
with open(meta_path, encoding="utf-8") as f:
|
75 |
+
reader = csv.DictReader(f, delimiter=";", quoting=csv.QUOTE_NONE)
|
76 |
+
for row in tqdm(reader):
|
77 |
+
metadata[row["file_name"]] = row
|
78 |
+
|
79 |
+
for i, path in enumerate(archives):
|
80 |
+
#for path, file in audio_archive:
|
81 |
+
_, filename = os.path.split(path)
|
82 |
+
file = os.path.join("data", split, filename)
|
83 |
+
if file in metadata:
|
84 |
+
result = dict(metadata[file])
|
85 |
+
print("Result: ", result)
|
86 |
+
with open(os.path.join(local_extracted_archive_paths, filename), 'rb') as wavfile:
|
87 |
+
input_wav = wavfile.read()
|
88 |
+
|
89 |
+
rate, data = read(io.BytesIO(input_wav))
|
90 |
+
|
91 |
+
path = os.path.join(local_extracted_archive_paths[i], path)
|
92 |
+
result["audio"] = {"path": path, "bytes": data}
|
93 |
+
result["path"] = path
|
94 |
+
yield path, result
|
95 |
+
else:
|
96 |
+
print("No file found")
|
97 |
+
yield None, None
|