kingjambal commited on
Commit
05d1df9
1 Parent(s): ff357d6

Upload 3 files

Browse files
Files changed (3) hide show
  1. col.csv +0 -0
  2. jambal2.py +72 -0
  3. test.zip +3 -0
col.csv ADDED
The diff for this file is too large to render. See raw diff
 
jambal2.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## -*- coding: utf-8 -*-
2
+ #"""dataset.ipynb
3
+
4
+ #Automatically generated by Colaboratory.
5
+
6
+ #Original file is located at
7
+ # https://colab.research.google.com/drive/1wOuPHcfW52hoC68q5L32HM1uFqNSXvAl
8
+ #"""
9
+
10
+ import csv
11
+ import os
12
+
13
+ import datasets
14
+
15
+ logger = datasets.logging.get_logger(__name__)
16
+
17
+ _DESCRIPTION = "Custom dataset for extracting audio files and matching sentences."
18
+
19
+ _DATA_URL = "https://huggingface.co/datasets/ugshanyu/jambal2/resolve/main" # Replace with the URL of your data
20
+
21
+ class CustomDataset(datasets.GeneratorBasedBuilder):
22
+
23
+ VERSION = datasets.Version("1.0.0")
24
+
25
+ def _info(self):
26
+ features = datasets.Features(
27
+ {
28
+ "audio": datasets.Audio(sampling_rate=48_000),
29
+ "sentence": datasets.Value("string"),
30
+ }
31
+ )
32
+
33
+ return datasets.DatasetInfo(
34
+ description=_DESCRIPTION,
35
+ features=features,
36
+ supervised_keys=("audio", "sentence"),
37
+ homepage=None,
38
+ citation=None,
39
+ )
40
+
41
+ def _split_generators(self, dl_manager):
42
+ audio_path = dl_manager.download_and_extract(_DATA_URL+"/test.zip")
43
+ csv_path = dl_manager.download_and_extract(_DATA_URL+"/col.csv")
44
+ # dir_inside_zip = os.listdir(audio_path)[0] # Assume the first directory is the one you're interested in
45
+ # audio_path = os.path.join(audio_path, dir_inside_zip)
46
+
47
+ return [
48
+ datasets.SplitGenerator(
49
+ name=datasets.Split.TRAIN,
50
+ gen_kwargs={"audio_path": audio_path, "csv_path": csv_path},
51
+ )
52
+ ]
53
+
54
+ def _generate_examples(self, audio_path, csv_path):
55
+ print(audio_path)
56
+ print(csv_path)
57
+ key = 0
58
+ print(os.listdir(audio_path))
59
+
60
+ with open(csv_path, encoding="utf-8") as csv_file:
61
+ csv_reader = csv.DictReader(csv_file)
62
+ for row in csv_reader:
63
+ original_sentence_id, sentence = row.values()
64
+ audio_file = f"{original_sentence_id}.mp3"
65
+ audio_file_path = os.path.join(audio_path, audio_file)
66
+ yield key, {
67
+ "audio": audio_file_path,
68
+ "sentence": sentence,
69
+ }
70
+ key += 1
71
+
72
+ #!pip install datasets
test.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f58857d9b0e5f3214a1e6a8d8d89178e5e5fec07752d22635967c05649fe57bc
3
+ size 19072287