Spaces:
Sleeping
Sleeping
Update midi_synthesizer.py
Browse files- midi_synthesizer.py +5 -0
midi_synthesizer.py
CHANGED
@@ -45,4 +45,9 @@ def synthesis(midi_opus, soundfont_path, sample_rate=44100):
|
|
45 |
fl.noteoff(c, p)
|
46 |
|
47 |
fl.delete()
|
|
|
|
|
|
|
|
|
|
|
48 |
return ss
|
|
|
45 |
fl.noteoff(c, p)
|
46 |
|
47 |
fl.delete()
|
48 |
+
if ss.shape[0] > 0:
|
49 |
+
max_val = np.abs(ss).max()
|
50 |
+
if max_val != 0:
|
51 |
+
ss = (ss / max_val) * np.iinfo(np.int16).max
|
52 |
+
ss = ss.astype(np.int16)
|
53 |
return ss
|