kingjambal commited on
Commit
8f39ad1
1 Parent(s): 1ab73cd

Delete jambal2.py

Browse files
Files changed (1) hide show
  1. jambal2.py +0 -72
jambal2.py DELETED
@@ -1,72 +0,0 @@
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
- print("sda")
60
- with open(csv_path, encoding="utf-8") as csv_file:
61
- print("csv_file",csv_file)
62
- csv_reader = csv.DictReader(csv_file)
63
- for row in csv_reader:
64
- original_sentence_id, sentence = row.values()
65
- audio_file = f"{original_sentence_id}.mp3"
66
- audio_file_path = os.path.join(audio_path, audio_file)
67
- yield key, {
68
- "audio": audio_file_path,
69
- "sentence": sentence,
70
- }
71
- key += 1
72
- #!pip install datasets