sebchw commited on
Commit
ea33064
1 Parent(s): 1857370

fix: bad iteration

Browse files
Files changed (1) hide show
  1. musdb18.py +5 -5
musdb18.py CHANGED
@@ -63,9 +63,9 @@ class Musdb18Dataset(datasets.GeneratorBasedBuilder):
63
  )
64
  ]
65
 
66
- def _generate_stem_dict(self, S, song_name, start):
67
  return {name: {"path": f"{song_name}/{name}",
68
- "array": S[i, start:start+self.WINDOW_SIZE, :], "sampling_rate": self.SAMPLING_RATE}
69
  for i, name in enumerate(self.INSTRUMENT_NAMES)}
70
 
71
  def _generate_examples(self, audio_path):
@@ -75,11 +75,11 @@ class Musdb18Dataset(datasets.GeneratorBasedBuilder):
75
  S, sr = stempeg.read_stems(
76
  str(stems_path), dtype=np.float32, multiprocess=False)
77
 
78
- for idx, start in enumerate(range(0, S.shape[1], self.WINDOW_SIZE)):
79
  yield id_, {
80
  "name": song_name,
81
  "n_window": idx,
82
- **self._generate_stem_dict(S, song_name, start)
83
  }
84
 
85
  id_ += 1
@@ -88,7 +88,7 @@ class Musdb18Dataset(datasets.GeneratorBasedBuilder):
88
  yield id_, {
89
  "name": song_name,
90
  "n_window": idx+1,
91
- **self._generate_stem_dict(S, song_name, start=S.shape[1] - self.WINDOW_SIZE)
92
  }
93
 
94
  id_ += 1
 
63
  )
64
  ]
65
 
66
+ def _generate_stem_dict(self, S, song_name, end):
67
  return {name: {"path": f"{song_name}/{name}",
68
+ "array": S[i, end-self.WINDOW_SIZE:end, :], "sampling_rate": self.SAMPLING_RATE}
69
  for i, name in enumerate(self.INSTRUMENT_NAMES)}
70
 
71
  def _generate_examples(self, audio_path):
 
75
  S, sr = stempeg.read_stems(
76
  str(stems_path), dtype=np.float32, multiprocess=False)
77
 
78
+ for idx, end in enumerate(range(self.WINDOW_SIZE, S.shape[1], self.WINDOW_SIZE)):
79
  yield id_, {
80
  "name": song_name,
81
  "n_window": idx,
82
+ **self._generate_stem_dict(S, song_name, end)
83
  }
84
 
85
  id_ += 1
 
88
  yield id_, {
89
  "name": song_name,
90
  "n_window": idx+1,
91
+ **self._generate_stem_dict(S, song_name, end=S.shape[1])
92
  }
93
 
94
  id_ += 1