Spaces:
Sleeping
Sleeping
asigalov61
commited on
Commit
•
06d58f4
1
Parent(s):
efd9432
Update app.py
Browse files
app.py
CHANGED
@@ -11,6 +11,8 @@ import json
|
|
11 |
import MIDI
|
12 |
from midi_synthesizer import synthesis
|
13 |
|
|
|
|
|
14 |
in_space = os.getenv("SYSTEM") == "spaces"
|
15 |
|
16 |
def run(search_prompt, mid=None, progress=gr.Progress()):
|
@@ -40,12 +42,19 @@ def run(search_prompt, mid=None, progress=gr.Progress()):
|
|
40 |
y.append(s[4])
|
41 |
c.append(colors[s[3]])
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
|
45 |
with open(f"output.mid", 'wb') as f:
|
46 |
f.write(MIDI.score2midi([mid_seq_ticks, mid_seq]))
|
47 |
audio = synthesis(MIDI.score2opus([mid_seq_ticks, mid_seq]), soundfont_path)
|
48 |
-
yield mdata, "output.mid", (44100, audio),
|
49 |
|
50 |
if __name__ == "__main__":
|
51 |
parser = argparse.ArgumentParser()
|
@@ -96,7 +105,7 @@ if __name__ == "__main__":
|
|
96 |
output_audio = gr.Audio(label="output audio", format="mp3", elem_id="midi_audio")
|
97 |
output_midi = gr.File(label="output midi", file_types=[".mid"])
|
98 |
output_midi_seq = gr.Textbox(label="output midi metadata")
|
99 |
-
output_plot = gr.
|
100 |
|
101 |
run_event = search_btn.click(run, [search_prompt],
|
102 |
[output_midi_seq, output_midi, output_audio, output_plot])
|
|
|
11 |
import MIDI
|
12 |
from midi_synthesizer import synthesis
|
13 |
|
14 |
+
import matplotlib.pyplot as plt
|
15 |
+
|
16 |
in_space = os.getenv("SYSTEM") == "spaces"
|
17 |
|
18 |
def run(search_prompt, mid=None, progress=gr.Progress()):
|
|
|
42 |
y.append(s[4])
|
43 |
c.append(colors[s[3]])
|
44 |
|
45 |
+
plt.close()
|
46 |
+
plt.figure(figsize=(14,5))
|
47 |
+
ax=plt.axes(title='Euterpe X Composition')
|
48 |
+
ax.set_facecolor('black')
|
49 |
+
|
50 |
+
plt.scatter(x,y, c=c)
|
51 |
+
plt.xlabel("Time")
|
52 |
+
plt.ylabel("Pitch")
|
53 |
|
54 |
with open(f"output.mid", 'wb') as f:
|
55 |
f.write(MIDI.score2midi([mid_seq_ticks, mid_seq]))
|
56 |
audio = synthesis(MIDI.score2opus([mid_seq_ticks, mid_seq]), soundfont_path)
|
57 |
+
yield mdata, "output.mid", (44100, audio), plt
|
58 |
|
59 |
if __name__ == "__main__":
|
60 |
parser = argparse.ArgumentParser()
|
|
|
105 |
output_audio = gr.Audio(label="output audio", format="mp3", elem_id="midi_audio")
|
106 |
output_midi = gr.File(label="output midi", file_types=[".mid"])
|
107 |
output_midi_seq = gr.Textbox(label="output midi metadata")
|
108 |
+
output_plot = gr.Plot(label="output midi plot")
|
109 |
|
110 |
run_event = search_btn.click(run, [search_prompt],
|
111 |
[output_midi_seq, output_midi, output_audio, output_plot])
|