jayliqinzhang commited on
Commit
9f2d453
·
verified ·
1 Parent(s): 6a83dba

Upload mumospee_small.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. mumospee_small.py +24 -22
mumospee_small.py CHANGED
@@ -22,7 +22,7 @@ _SPLITS = ["train", "validation", "test"]
22
 
23
  # BuilderConfig class for your dataset
24
  class MumospeeDatasetConfig(datasets.BuilderConfig):
25
- def __init__(self, split=None, language=None, tag=None, **kwargs):
26
  super().__init__(**kwargs)
27
  self.split=split
28
  self.language = language
@@ -42,7 +42,7 @@ class MumospeeDataset(datasets.GeneratorBasedBuilder):
42
  name="default",
43
  version=datasets.Version("1.0.0"),
44
  description=_DESCRIPTION,
45
- split=None,
46
  language=None,
47
  tag=None
48
  )
@@ -68,7 +68,7 @@ class MumospeeDataset(datasets.GeneratorBasedBuilder):
68
  license=_LICENSE,
69
  )
70
 
71
- def _adapt_args(self, arg, accepted_arg):
72
  """
73
  Adpat the input and make sure it outs as list
74
  and all the elements within the list are accpeted.
@@ -76,15 +76,15 @@ class MumospeeDataset(datasets.GeneratorBasedBuilder):
76
 
77
  if arg and isinstance(arg, str):
78
  adapted_arg = [arg]
79
- for aa in adapted_arg:
80
- if aa not in accepted_arg:
81
- raise ValueError(f"Invalid input: '{aa}'. Accepted values are: {', '.join(accepted_arg)}.")
82
  else:
83
  adapted_arg = arg
84
 
 
 
 
 
85
 
86
  return adapted_arg
87
-
88
 
89
 
90
  def _split_generators(self, dl_manager):
@@ -141,10 +141,12 @@ class MumospeeDataset(datasets.GeneratorBasedBuilder):
141
 
142
  data_split = data[data["split"] == split]
143
 
 
144
  language_list = self._adapt_args(language, _LANGUAGES)
145
  tag_list = self._adapt_args(tag, _TAGS)
146
 
147
-
 
148
  if language_list:
149
  data_split = data_split[data_split["language"].isin(language_list)]
150
  if tag_list:
@@ -155,21 +157,21 @@ class MumospeeDataset(datasets.GeneratorBasedBuilder):
155
  print(f"No data found for split='{split}', language='{language}', tag='{tag}'. Returning None.")
156
  return # This exits the generator without yielding any examples
157
 
 
158
 
159
-
160
- for i, row in data_split.iterrows():
161
- yield i, {
162
- "path": row["path"],
163
- #"local_path": row["local_path"],
164
- "url": row["url"],
165
- "type": row["type"],
166
- "duration": float(row["duration"]),
167
- "language": row["language"],
168
- "transcript": row["transcript"],
169
- "tag": row["tag"],
170
- "split": row["split"],
171
- "license": row["license"]
172
- }
173
 
174
 
175
 
 
22
 
23
  # BuilderConfig class for your dataset
24
  class MumospeeDatasetConfig(datasets.BuilderConfig):
25
+ def __init__(self, split, language=None, tag=None, **kwargs):
26
  super().__init__(**kwargs)
27
  self.split=split
28
  self.language = language
 
42
  name="default",
43
  version=datasets.Version("1.0.0"),
44
  description=_DESCRIPTION,
45
+ split="train",
46
  language=None,
47
  tag=None
48
  )
 
68
  license=_LICENSE,
69
  )
70
 
71
+ def _adapt_args(arg, accepted_arg):
72
  """
73
  Adpat the input and make sure it outs as list
74
  and all the elements within the list are accpeted.
 
76
 
77
  if arg and isinstance(arg, str):
78
  adapted_arg = [arg]
 
 
 
79
  else:
80
  adapted_arg = arg
81
 
82
+ for aa in adapted_arg:
83
+ if aa not in accepted_arg:
84
+ raise ValueError(f"Invalid input: '{aa}'. Accepted values are: {', '.join(accepted_arg)}.")
85
+
86
 
87
  return adapted_arg
 
88
 
89
 
90
  def _split_generators(self, dl_manager):
 
141
 
142
  data_split = data[data["split"] == split]
143
 
144
+
145
  language_list = self._adapt_args(language, _LANGUAGES)
146
  tag_list = self._adapt_args(tag, _TAGS)
147
 
148
+ print(f"input language are : {language_list}")
149
+ print(f"input tag are {tag_list}")
150
  if language_list:
151
  data_split = data_split[data_split["language"].isin(language_list)]
152
  if tag_list:
 
157
  print(f"No data found for split='{split}', language='{language}', tag='{tag}'. Returning None.")
158
  return # This exits the generator without yielding any examples
159
 
160
+ else:
161
 
162
+ for i, row in data_split.iterrows():
163
+ yield i, {
164
+ "path": row["path"],
165
+ #"local_path": row["local_path"],
166
+ "url": row["url"],
167
+ "type": row["type"],
168
+ "duration": float(row["duration"]),
169
+ "language": row["language"],
170
+ "transcript": row["transcript"],
171
+ "tag": row["tag"],
172
+ "split": row["split"],
173
+ "license": row["license"]
174
+ }
 
175
 
176
 
177