asigalov61 commited on
Commit
22ee648
1 Parent(s): 5b68d53

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -5
app.py CHANGED
@@ -13,6 +13,8 @@ import tqdm
13
  from midi_synthesizer import synthesis
14
  import TMIDIX
15
 
 
 
16
  in_space = os.getenv("SYSTEM") == "spaces"
17
 
18
  #=================================================================================================
@@ -151,8 +153,6 @@ def GenerateMIDI(progress=gr.Progress()):
151
  itrack += 1
152
 
153
  audio = synthesis([500, output1], 'SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2')
154
-
155
- midi_plot = []
156
 
157
  x = []
158
  y =[]
@@ -165,9 +165,15 @@ def GenerateMIDI(progress=gr.Progress()):
165
  y.append(s[4])
166
  c.append(colors[s[3]])
167
 
168
- midi_plot.append([x, y, c])
 
 
 
 
 
 
169
 
170
- yield [500, output1], midi_plot, "Allegro-Music-Transformer-Music-Composition.mid", (44100, audio)
171
 
172
  #=================================================================================================
173
 
@@ -196,7 +202,7 @@ if __name__ == "__main__":
196
  run_btn = gr.Button("generate", variant="primary")
197
 
198
  output_midi_seq = gr.Variable()
199
- output_plot = gr.ScatterPlot(label="output plot")
200
  output_audio = gr.Audio(label="output audio", format="mp3", elem_id="midi_audio")
201
  output_midi = gr.File(label="output midi", file_types=[".mid"])
202
  run_event = run_btn.click(GenerateMIDI, [], [output_midi_seq, output_plot, output_midi, output_audio])
 
13
  from midi_synthesizer import synthesis
14
  import TMIDIX
15
 
16
+ import matplotlib.pyplot as plt
17
+
18
  in_space = os.getenv("SYSTEM") == "spaces"
19
 
20
  #=================================================================================================
 
153
  itrack += 1
154
 
155
  audio = synthesis([500, output1], 'SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2')
 
 
156
 
157
  x = []
158
  y =[]
 
165
  y.append(s[4])
166
  c.append(colors[s[3]])
167
 
168
+ fig = plt.figure(figsize=(14,5))
169
+ ax=plt.axes(title=fname)
170
+ ax.set_facecolor('black')
171
+
172
+ plt.scatter(x,y, c=c)
173
+ plt.xlabel("Time")
174
+ plt.ylabel("Pitch")
175
 
176
+ yield [500, output1], fig, "Allegro-Music-Transformer-Music-Composition.mid", (44100, audio)
177
 
178
  #=================================================================================================
179
 
 
202
  run_btn = gr.Button("generate", variant="primary")
203
 
204
  output_midi_seq = gr.Variable()
205
+ output_plot = gr.Plot(label="output plot")
206
  output_audio = gr.Audio(label="output audio", format="mp3", elem_id="midi_audio")
207
  output_midi = gr.File(label="output midi", file_types=[".mid"])
208
  run_event = run_btn.click(GenerateMIDI, [], [output_midi_seq, output_plot, output_midi, output_audio])