Delete sesge.py
Browse files
sesge.py
DELETED
@@ -1,120 +0,0 @@
|
|
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 |
-
"""
|
37 |
-
description = (
|
38 |
-
f"Common Voice speech to text dataset in {self.language} released on {self.release_date}. "
|
39 |
-
f"The dataset comprises {self.validated_hr} hours of validated transcribed speech data "
|
40 |
-
f"out of {self.total_hr} hours in total from {self.num_speakers} speakers. "
|
41 |
-
f"The dataset contains {self.num_clips} audio clips and has a size of {self.size_human}."
|
42 |
-
)
|
43 |
-
"""
|
44 |
-
|
45 |
-
super(SesgeConfig, self).__init__(
|
46 |
-
name=name,
|
47 |
-
**kwargs,
|
48 |
-
)
|
49 |
-
|
50 |
-
class Sesge():
|
51 |
-
|
52 |
-
BUILDER_CONFIGS = [
|
53 |
-
SesgeConfig(
|
54 |
-
name="sesge",
|
55 |
-
version=1.0,
|
56 |
-
language='eng',
|
57 |
-
release_date="2024-10-8",
|
58 |
-
)
|
59 |
-
]
|
60 |
-
|
61 |
-
def _info(self):
|
62 |
-
total_languages = 1
|
63 |
-
total_valid_hours = 1
|
64 |
-
description = (
|
65 |
-
"Common Voice is Mozilla's initiative to help teach machines how real people speak. "
|
66 |
-
f"The dataset currently consists of {total_valid_hours} validated hours of speech "
|
67 |
-
f" in {total_languages} languages, but more voices and languages are always added."
|
68 |
-
)
|
69 |
-
features = datasets.Features(
|
70 |
-
{
|
71 |
-
"audio": datasets.features.Audio(sampling_rate=48_000),
|
72 |
-
"sentence": datasets.Value("string"),
|
73 |
-
}
|
74 |
-
)
|
75 |
-
|
76 |
-
def _generate_examples(self, local_extracted_archive_paths, archives, meta_path, split):
|
77 |
-
archives = os.listdir(archives)
|
78 |
-
print(archives)
|
79 |
-
metadata = {}
|
80 |
-
with open(meta_path, encoding="utf-8") as f:
|
81 |
-
reader = csv.DictReader(f, delimiter=";", quoting=csv.QUOTE_NONE)
|
82 |
-
for row in tqdm(reader):
|
83 |
-
metadata[row["file_name"]] = row
|
84 |
-
#print(metadata)
|
85 |
-
for i, path in enumerate(archives):
|
86 |
-
#for path, file in audio_archive:
|
87 |
-
_, filename = os.path.split(path)
|
88 |
-
file = os.path.join("data", split, filename)
|
89 |
-
#print(filename)
|
90 |
-
if file in metadata:
|
91 |
-
result = dict(metadata[file])
|
92 |
-
print("Result: ", result)
|
93 |
-
with open(os.path.join(local_extracted_archive_paths, filename), 'rb') as wavfile:
|
94 |
-
input_wav = wavfile.read()
|
95 |
-
|
96 |
-
rate, data = read(io.BytesIO(input_wav))
|
97 |
-
|
98 |
-
# data is a numpy ND array representing the audio data. Let's do some stuff with it
|
99 |
-
reversed_data = data[::-1] #reversing it
|
100 |
-
|
101 |
-
#then, let's save it to a BytesIO object, which is a buffer for bytes object
|
102 |
-
bytes_wav = bytes()
|
103 |
-
byte_io = io.BytesIO(bytes_wav)
|
104 |
-
write(byte_io, rate, reversed_data)
|
105 |
-
|
106 |
-
output_wav = byte_io.read()
|
107 |
-
# set the audio feature and the path to the extracted file
|
108 |
-
path = os.path.join(local_extracted_archive_paths[i], path)
|
109 |
-
result["audio"] = {"path": path, "bytes": data}
|
110 |
-
result["path"] = path
|
111 |
-
yield path, result
|
112 |
-
else:
|
113 |
-
print("No file found")
|
114 |
-
yield None, None
|
115 |
-
|
116 |
-
if __name__ == '__main__':
|
117 |
-
data = Sesge()
|
118 |
-
gen = data._generate_examples("/Users/rafael/Desktop/TFM/Transformes/Demint/Base de datos/COnver/datos/", "/Users/rafael/Desktop/TFM/Transformes/Demint/Base de datos/COnver/datos/", "/Users/rafael/Desktop/TFM/Transformes/Demint/Base de datos/COnver/metadata.csv", "train")
|
119 |
-
|
120 |
-
print(next(gen))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|