Update mypin-voice-dataset.py
Browse files- mypin-voice-dataset.py +4 -6
mypin-voice-dataset.py
CHANGED
@@ -26,8 +26,7 @@ class MyDataset(datasets.GeneratorBasedBuilder):
|
|
26 |
gen_kwargs={
|
27 |
"filepath": metadata,
|
28 |
"audio_dir": data_dir,
|
29 |
-
"split": "train"
|
30 |
-
"split_ratio": 0.8,
|
31 |
},
|
32 |
),
|
33 |
datasets.SplitGenerator(
|
@@ -35,13 +34,12 @@ class MyDataset(datasets.GeneratorBasedBuilder):
|
|
35 |
gen_kwargs={
|
36 |
"filepath": metadata,
|
37 |
"audio_dir": data_dir,
|
38 |
-
"split": "eval"
|
39 |
-
"split_ratio": 0.2,
|
40 |
},
|
41 |
)
|
42 |
]
|
43 |
|
44 |
-
def _generate_examples(self, filepath, audio_dir, split
|
45 |
# Read and parse the metadata JSONL file
|
46 |
with open(filepath, "r", encoding="utf-8") as f:
|
47 |
data = [json.loads(line) for line in f]
|
@@ -50,7 +48,7 @@ class MyDataset(datasets.GeneratorBasedBuilder):
|
|
50 |
random.shuffle(data)
|
51 |
|
52 |
# Calculate split index for training and evaluation
|
53 |
-
split_index = int(len(data) *
|
54 |
if split == "train":
|
55 |
examples = data[:split_index]
|
56 |
else:
|
|
|
26 |
gen_kwargs={
|
27 |
"filepath": metadata,
|
28 |
"audio_dir": data_dir,
|
29 |
+
"split": "train"
|
|
|
30 |
},
|
31 |
),
|
32 |
datasets.SplitGenerator(
|
|
|
34 |
gen_kwargs={
|
35 |
"filepath": metadata,
|
36 |
"audio_dir": data_dir,
|
37 |
+
"split": "eval"
|
|
|
38 |
},
|
39 |
)
|
40 |
]
|
41 |
|
42 |
+
def _generate_examples(self, filepath, audio_dir, split):
|
43 |
# Read and parse the metadata JSONL file
|
44 |
with open(filepath, "r", encoding="utf-8") as f:
|
45 |
data = [json.loads(line) for line in f]
|
|
|
48 |
random.shuffle(data)
|
49 |
|
50 |
# Calculate split index for training and evaluation
|
51 |
+
split_index = int(len(data) * 0.8)
|
52 |
if split == "train":
|
53 |
examples = data[:split_index]
|
54 |
else:
|