felixgwu commited on
Commit
df91a3f
1 Parent(s): 8c1b8b2

fix loading bug

Browse files
Files changed (1) hide show
  1. slue-phase-2.py +13 -14
slue-phase-2.py CHANGED
@@ -88,20 +88,18 @@ class SLUE2(datasets.GeneratorBasedBuilder):
88
  def _info(self):
89
  if self.config.name == "hvb":
90
  features = {
91
- "id": datasets.Value("string"),
92
  "audio": datasets.Audio(sampling_rate=16_000),
93
  "speaker_id": datasets.Value("string"),
94
  "text": datasets.Value("string"),
95
  "utt_index": datasets.Value("int32"),
96
  "channel": datasets.Value("int32"),
97
  "role": datasets.Value("string"),
98
- "start_ms": datasets.Value("float64"),
99
- "duration_ms": datasets.Value("float64"),
100
  "intent": datasets.Value("string"),
101
  "dialog_acts": datasets.Sequence(
102
- {
103
- "type": datasets.Value("string"),
104
- }
105
  ),
106
  }
107
  return datasets.DatasetInfo(
@@ -160,21 +158,22 @@ class SLUE2(datasets.GeneratorBasedBuilder):
160
 
161
  for idx, row in enumerate(reader):
162
  if self.config.name == "hvb":
 
163
  audio_file = os.path.join(
164
- data_dir, "slue-hvb", row["split"],
165
- f'{row["id"]}_{row["start_ms"]}_{row["start_ms"] + row["duration_ms"]}.wav'
166
  )
167
  example = {
168
- "id": row["id"],
169
  "audio": audio_file,
170
  "speaker_id": row["speaker_id"],
171
  "text": row["text"],
172
- "utt_index": row["utt_index"],
173
- "channel": row["channel"],
174
  "role": row["role"],
175
- "start_ms": row["start_ms"],
176
- "duration_ms": row["duration_ms"],
177
  "intent": row["intent"],
178
- "dialog_acts": row["dialog_acts"],
179
  }
180
  yield idx, example
 
88
  def _info(self):
89
  if self.config.name == "hvb":
90
  features = {
91
+ "issue_id": datasets.Value("string"),
92
  "audio": datasets.Audio(sampling_rate=16_000),
93
  "speaker_id": datasets.Value("string"),
94
  "text": datasets.Value("string"),
95
  "utt_index": datasets.Value("int32"),
96
  "channel": datasets.Value("int32"),
97
  "role": datasets.Value("string"),
98
+ "start_ms": datasets.Value("int32"),
99
+ "duration_ms": datasets.Value("int32"),
100
  "intent": datasets.Value("string"),
101
  "dialog_acts": datasets.Sequence(
102
+ datasets.Value("string"),
 
 
103
  ),
104
  }
105
  return datasets.DatasetInfo(
 
158
 
159
  for idx, row in enumerate(reader):
160
  if self.config.name == "hvb":
161
+ split = "test" if "test" in filepath else "dev" if "dev" in filepath else "fine-tune"
162
  audio_file = os.path.join(
163
+ data_dir, split,
164
+ f'{row["issue_id"]}_{row["start_ms"]}_{int(row["start_ms"]) + int(row["duration_ms"])}.wav'
165
  )
166
  example = {
167
+ "issue_id": row["issue_id"],
168
  "audio": audio_file,
169
  "speaker_id": row["speaker_id"],
170
  "text": row["text"],
171
+ "utt_index": int(row["utt_index"]),
172
+ "channel": int(row["channel"]),
173
  "role": row["role"],
174
+ "start_ms": int(row["start_ms"]),
175
+ "duration_ms": int(row["duration_ms"]),
176
  "intent": row["intent"],
177
+ "dialog_acts": eval(row.get("dialog_acts", "[]")),
178
  }
179
  yield idx, example