Spaces:
Running
Running
Commit
·
881a14f
1
Parent(s):
364607e
testing app
Browse files
app.py
CHANGED
|
@@ -14,23 +14,23 @@ from miditok import REMI, TokenizerConfig
|
|
| 14 |
from pathlib import Path
|
| 15 |
|
| 16 |
|
| 17 |
-
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
#
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
|
| 35 |
|
| 36 |
# def post_processing(input_midi_path: str, output_midi_path: str):
|
|
|
|
| 14 |
from pathlib import Path
|
| 15 |
|
| 16 |
|
| 17 |
+
def save_wav(filepath):
|
| 18 |
+
# Extract the directory and the stem (filename without extension)
|
| 19 |
+
directory = os.path.dirname(filepath)
|
| 20 |
+
stem = os.path.splitext(os.path.basename(filepath))[0]
|
| 21 |
+
|
| 22 |
+
# Construct the full paths for MIDI and WAV files
|
| 23 |
+
midi_filepath = os.path.join(directory, f"{stem}.mid")
|
| 24 |
+
wav_filepath = os.path.join(directory, f"{stem}.wav")
|
| 25 |
+
|
| 26 |
+
# Run the fluidsynth command to convert MIDI to WAV
|
| 27 |
+
process = subprocess.Popen(
|
| 28 |
+
f"fluidsynth -r 16000 soundfont.sf2 -g 1.0 --quiet --no-shell {midi_filepath} -T wav -F {wav_filepath} > /dev/null",
|
| 29 |
+
shell=True
|
| 30 |
+
)
|
| 31 |
+
process.wait()
|
| 32 |
+
|
| 33 |
+
return wav_filepath
|
| 34 |
|
| 35 |
|
| 36 |
# def post_processing(input_midi_path: str, output_midi_path: str):
|