Datasets:

Languages:
English
ArXiv:
License:
File size: 4,500 Bytes
4bd48fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
import csv
import os
import json

import datasets
from datasets.utils.py_utils import size_str
from tqdm import tqdm

from scipy.io.wavfile import read, write
import io

#from .release_stats import STATS

_CITATION = """\
@inproceedings{demint2024,
  author = {Pérez-Ortiz, Juan Antonio and 
    Esplà-Gomis, Miquel and 
    Sánchez-Cartagena, Víctor M. and 
    Sánchez-Martínez, Felipe and 
    Chernysh, Roman and 
    Mora-Rodríguez, Gabriel and 
    Berezhnoy, Lev},
  title = {{DeMINT}: Automated Language Debriefing for English Learners via {AI} 
           Chatbot Analysis of Meeting Transcripts},
  booktitle = {Proceedings of the 13th Workshop on NLP for Computer Assisted Language Learning},
  month = october,
  year = {2024},
  url = {https://aclanthology.org/volumes/2024.nlp4call-1/},
}
"""

class SesgeConfig(datasets.BuilderConfig):
    def __init__(self, name, version, **kwargs):
        self.language = kwargs.pop("language", None)
        self.release_date = kwargs.pop("release_date", None)
        """
        description = (
            f"Common Voice speech to text dataset in {self.language} released on {self.release_date}. "
            f"The dataset comprises {self.validated_hr} hours of validated transcribed speech data "
            f"out of {self.total_hr} hours in total from {self.num_speakers} speakers. "
            f"The dataset contains {self.num_clips} audio clips and has a size of {self.size_human}."
        )
        """

        super(SesgeConfig, self).__init__(
            name=name,
            **kwargs,
        )

class Sesge():

    BUILDER_CONFIGS = [
        SesgeConfig(
            name="sesge",
            version=1.0,
            language='eng',
            release_date="2024-10-8",
        )
    ]

    def _info(self):
        total_languages = 1
        total_valid_hours = 1
        description = (
            "Common Voice is Mozilla's initiative to help teach machines how real people speak. "
            f"The dataset currently consists of {total_valid_hours} validated hours of speech "
            f" in {total_languages} languages, but more voices and languages are always added."
        )
        features = datasets.Features(
            {
                "audio": datasets.features.Audio(sampling_rate=48_000),
                "sentence": datasets.Value("string"),
            }
        )

    def _generate_examples(self, local_extracted_archive_paths, archives, meta_path, split):
        archives = os.listdir(archives)
        print(archives)
        metadata = {}
        with open(meta_path, encoding="utf-8") as f:
            reader = csv.DictReader(f, delimiter=";", quoting=csv.QUOTE_NONE)
            for row in tqdm(reader):
                metadata[row["file_name"]] = row
        #print(metadata)
        for i, path in enumerate(archives):
            #for path, file in audio_archive:
            _, filename = os.path.split(path)
            file = os.path.join("data", split, filename)
            #print(filename)
            if file in metadata:
                result = dict(metadata[file])
                print("Result: ", result)
                with open(os.path.join(local_extracted_archive_paths, filename), 'rb') as wavfile:
                    input_wav = wavfile.read()

                rate, data = read(io.BytesIO(input_wav))

                # data is a numpy ND array representing the audio data. Let's do some stuff with it
                reversed_data = data[::-1] #reversing it

                #then, let's save it to a BytesIO object, which is a buffer for bytes object
                bytes_wav = bytes()
                byte_io = io.BytesIO(bytes_wav)
                write(byte_io, rate, reversed_data)

                output_wav = byte_io.read()
                # set the audio feature and the path to the extracted file
                path = os.path.join(local_extracted_archive_paths[i], path)
                result["audio"] = {"path": path, "bytes": data}
                result["path"] = path
                yield path, result
            else:
                print("No file found")
                yield None, None

if __name__ == '__main__':
    data = Sesge()
    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")

    print(next(gen))