ugshanyu commited on
Commit
e43cd80
·
1 Parent(s): 38a2157

Create jambal4

Browse files
Files changed (1) hide show
  1. jambal4 +59 -0
jambal4 ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import csv
2
+ import os
3
+
4
+ import datasets
5
+
6
+ logger = datasets.logging.get_logger(__name__)
7
+
8
+ _DESCRIPTION = "Custom dataset for extracting audio files and matching sentences."
9
+
10
+ _DATA_URL = "https://huggingface.co/datasets/ugshanyu/jambal4/resolve/main" # Replace with the URL of your data
11
+
12
+ class CustomDataset(datasets.GeneratorBasedBuilder):
13
+
14
+ VERSION = datasets.Version("1.0.0")
15
+
16
+ def _info(self):
17
+ features = datasets.Features(
18
+ {
19
+ "audio": datasets.Audio(sampling_rate=48_000),
20
+ "sentence": datasets.Value("string"),
21
+ }
22
+ )
23
+
24
+ return datasets.DatasetInfo(
25
+ description=_DESCRIPTION,
26
+ features=features,
27
+ supervised_keys=("audio", "sentence"),
28
+ homepage=None,
29
+ citation=None,
30
+ )
31
+
32
+ def _split_generators(self, dl_manager):
33
+ audio_path = dl_manager.download_and_extract(_DATA_URL+"/test.zip")
34
+ csv_path = dl_manager.download_and_extract(_DATA_URL+"/testt.csv")
35
+
36
+ return [
37
+ datasets.SplitGenerator(
38
+ name=datasets.Split.TRAIN,
39
+ gen_kwargs={"audio_path": audio_path, "csv_path": csv_path},
40
+ )
41
+ ]
42
+
43
+ def _generate_examples(self, audio_path, csv_path):
44
+ print(audio_path)
45
+ print(csv_path)
46
+ key = 0
47
+ print(os.listdir(audio_path))
48
+
49
+ with open(csv_path, encoding="utf-8") as csv_file:
50
+ csv_reader = csv.DictReader(csv_file)
51
+ for row in csv_reader:
52
+ original_sentence_id, sentence, locale = row.values()
53
+ audio_file = f"{original_sentence_id}.mp3"
54
+ audio_file_path = os.path.join(audio_path, audio_file)
55
+ yield key, {
56
+ "audio": audio_file_path,
57
+ "sentence": sentence,
58
+ }
59
+ key += 1