Spaces:
Runtime error
Runtime error
File size: 2,054 Bytes
7cbc42d ff647b0 1de73a8 789718b ff647b0 3f41985 a973402 3f41985 a973402 50efdde f19aeec 776a79b f19aeec 776a79b f19aeec 50efdde fad0f53 c62f15c fad0f53 a1f6dfc c62f15c a1f6dfc a9764fc 9cc5612 dbd8bfc a9764fc 3f41985 ff647b0 1de73a8 a973402 ff647b0 c7cb9a5 ff647b0 c7cb9a5 7cbc42d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
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)
# stdout = result.stdout
# paths = stdout.decode('utf-8').strip().split(':')
# from pathlib import Path
# paths = [Path(path) for path in paths]
# for path in paths:
# print(path)
# print(os.listdir(path))
# print('-'*10)
# subprocess.run(['/home/user/.local/bin/install_fluidsynth_with_soundfonts_osx.sh'], shell=True)
# subprocess.run(['cat /home/user/.local/bin/install_fluidsynth_with_soundfonts_osx.sh'], shell=True)
subprocess.run(['cat /root/packages.txt'], shell=True)
# subprocess.run(['apt-get install fluidsynth'], shell=True)
# results = subprocess.run(['find / | grep "fluidsynth"'], capture_output=True, shell=True)
# print(results.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() |