edit files
Browse files- su_id_asr_split.py +10 -9
su_id_asr_split.py
CHANGED
@@ -56,27 +56,30 @@ class SuIdASR(datasets.GeneratorBasedBuilder):
|
|
56 |
return datasets.DatasetInfo(features=features)
|
57 |
|
58 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
59 |
-
# Print a message indicating the download process has started
|
60 |
print("Downloading the dataset...")
|
61 |
|
|
|
|
|
|
|
|
|
|
|
62 |
return [
|
63 |
datasets.SplitGenerator(
|
64 |
name=datasets.Split.TRAIN,
|
65 |
-
gen_kwargs={"filepath":
|
66 |
),
|
67 |
datasets.SplitGenerator(
|
68 |
name=datasets.Split.VALIDATION,
|
69 |
-
gen_kwargs={"filepath":
|
70 |
),
|
71 |
datasets.SplitGenerator(
|
72 |
name=datasets.Split.TEST,
|
73 |
-
gen_kwargs={"filepath":
|
74 |
),
|
75 |
]
|
76 |
|
77 |
def _generate_examples(self, filepath: str):
|
78 |
"""Yields examples as (key, example) tuples."""
|
79 |
-
# Attempt to open the TSV file
|
80 |
try:
|
81 |
with open(filepath, "r") as f:
|
82 |
tsv_reader = csv.reader(f, delimiter="\t")
|
@@ -101,10 +104,8 @@ class SuIdASR(datasets.GeneratorBasedBuilder):
|
|
101 |
"text": text,
|
102 |
}
|
103 |
else:
|
104 |
-
# Handle the case where the audio file does not exist
|
105 |
print(f"Audio file does not exist: {wav_path}. Skipping this entry.")
|
106 |
|
107 |
-
# Print a message indicating the download is complete
|
108 |
print(f"Completed loading data from {filepath}.")
|
109 |
|
110 |
except FileNotFoundError:
|
@@ -112,9 +113,9 @@ class SuIdASR(datasets.GeneratorBasedBuilder):
|
|
112 |
except Exception as e:
|
113 |
print(f"An error occurred: {e}")
|
114 |
|
115 |
-
#
|
116 |
try:
|
117 |
-
dataset = datasets.load_dataset(
|
118 |
print("Dataset loaded successfully.")
|
119 |
print(dataset)
|
120 |
|
|
|
56 |
return datasets.DatasetInfo(features=features)
|
57 |
|
58 |
def _split_generators(self, dl_manager: datasets.DownloadManager) -> List[datasets.SplitGenerator]:
|
|
|
59 |
print("Downloading the dataset...")
|
60 |
|
61 |
+
# Download the files
|
62 |
+
train_file = dl_manager.download(_URLs["su_id_asr_train"])
|
63 |
+
dev_file = dl_manager.download(_URLs["su_id_asr_dev"])
|
64 |
+
test_file = dl_manager.download(_URLs["su_id_asr_test"])
|
65 |
+
|
66 |
return [
|
67 |
datasets.SplitGenerator(
|
68 |
name=datasets.Split.TRAIN,
|
69 |
+
gen_kwargs={"filepath": train_file},
|
70 |
),
|
71 |
datasets.SplitGenerator(
|
72 |
name=datasets.Split.VALIDATION,
|
73 |
+
gen_kwargs={"filepath": dev_file},
|
74 |
),
|
75 |
datasets.SplitGenerator(
|
76 |
name=datasets.Split.TEST,
|
77 |
+
gen_kwargs={"filepath": test_file},
|
78 |
),
|
79 |
]
|
80 |
|
81 |
def _generate_examples(self, filepath: str):
|
82 |
"""Yields examples as (key, example) tuples."""
|
|
|
83 |
try:
|
84 |
with open(filepath, "r") as f:
|
85 |
tsv_reader = csv.reader(f, delimiter="\t")
|
|
|
104 |
"text": text,
|
105 |
}
|
106 |
else:
|
|
|
107 |
print(f"Audio file does not exist: {wav_path}. Skipping this entry.")
|
108 |
|
|
|
109 |
print(f"Completed loading data from {filepath}.")
|
110 |
|
111 |
except FileNotFoundError:
|
|
|
113 |
except Exception as e:
|
114 |
print(f"An error occurred: {e}")
|
115 |
|
116 |
+
# Load the dataset
|
117 |
try:
|
118 |
+
dataset = datasets.load_dataset(__name__) # Use the current module name
|
119 |
print("Dataset loaded successfully.")
|
120 |
print(dataset)
|
121 |
|