Simon Stolarczyk
Accurately capture output.
d259f0f
raw
history blame
1.4 kB
import gradio as gr
# from musicautobot.numpy_encode import file2stream
from musicautobot.utils.setup_musescore import play_wav
from music21.midi.translate import midiFileToStream
from pathlib import Path
from midi2audio import FluidSynth
import subprocess
import os
print(os.getcwd())
# print(os.listdir())
# print(os.listdir('..')) # ['.bash_logout', '.bashrc', '.profile', 'app', '.cache', '.local']
# print(os.listdir('../.local')) # ['bin', 'lib', 'etc', 'share']
# print(os.listdir('../..')) # ['user']
# print(os.listdir('../../..')) # ['bin', 'boot', 'dev', 'etc', 'home', 'lib', 'lib64', 'media', 'mnt', 'opt', 'proc', 'root', 'run', 'sbin', 'srv', 'sys', 'tmp', 'usr', 'var', '.dockerenv']
print(os.listdir('../../../bin'))
result = subprocess.run(['echo $PATH'], capture_output=True, shell=True)
print(result.stdout)
# subprocess.run(['PATH=$PATH:~/opt/bin'])
# subprocess.run(['PATH=$PATH:~/opt/bin/fluidsynth'])
# subprocess.run(['fluidsynth'], shell=True)
def process_midi(midi_file):
name = Path(midi_file.name)
# stream = midiFileToStream(midi_file)
# output_wav = play_wav(stream)
# FluidSynth("../usr/share/sounds/sf2/FluidR3_GM.sf2").midi_to_audio(name, 'test.wav')
FluidSynth("FluidR3_GM.sf2").midi_to_audio(name, 'test.wav')
return output_wav
iface = gr.Interface(
fn=process_midi,
inputs="file",
outputs="audio"
)
iface.launch()