Spaces:
Runtime error
Runtime error
Update src/music/pipeline/processed2encoded.py
Browse files
src/music/pipeline/processed2encoded.py
CHANGED
|
@@ -30,23 +30,23 @@ def processed2encoded(processed_path, encoded_path=None, augmentation=False, nb_
|
|
| 30 |
if augmentation:
|
| 31 |
assert isinstance(nb_aug, int)
|
| 32 |
error_msg = 'Error in encoding. '
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
except:
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
return None, error_msg + ' Yes.'
|
| 52 |
|
|
|
|
| 30 |
if augmentation:
|
| 31 |
assert isinstance(nb_aug, int)
|
| 32 |
error_msg = 'Error in encoding. '
|
| 33 |
+
# try:
|
| 34 |
+
error_msg = 'Error in encoding midi?'
|
| 35 |
+
nb_noise = 1 if noise_injection else 0
|
| 36 |
+
encoded_main, encoded_aug, encoded_noisy = encode_midi_structured(processed_path, nb_aug, nb_noise)
|
| 37 |
+
|
| 38 |
+
# make sure augmentations are not out of bounds
|
| 39 |
+
error_msg = ' Nope. Error in saving encoding?'
|
| 40 |
+
with open(encoded_path, 'wb') as f:
|
| 41 |
+
pickle.dump(dict(main=encoded_main, aug=encoded_aug, noisy=encoded_noisy), f)
|
| 42 |
+
error_msg = ' Nope.'
|
| 43 |
+
if verbose:
|
| 44 |
+
extra = f' Saved to {encoded_path}' if encoded_path else ''
|
| 45 |
+
print(' ' * (level + 2) + f'Success! {extra}')
|
| 46 |
+
return encoded_path, ''
|
| 47 |
+
#except:
|
| 48 |
+
# if verbose: print(' ' * (level + 2) + 'Transcription failed.')
|
| 49 |
+
# if os.path.exists(encoded_path):
|
| 50 |
+
# os.remove(encoded_path)
|
| 51 |
+
#return None, error_msg + ' Yes.'
|
| 52 |
|