asigalov61 commited on
Commit
66cd8ce
1 Parent(s): fd58682

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -30
app.py CHANGED
@@ -28,7 +28,7 @@ in_space = os.getenv("SYSTEM") == "spaces"
28
 
29
  #==========================================================================================================
30
 
31
- def render_midi(input_midi, render_as_is, extract_melody, transform):
32
 
33
  print('=' * 70)
34
  print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
@@ -101,29 +101,6 @@ def render_midi(input_midi, render_as_is, extract_melody, transform):
101
 
102
  print('Sample INTs', escore[:5])
103
  print('=' * 70)
104
-
105
- x = []
106
- y = []
107
- c = []
108
-
109
- colors = ['red', 'yellow', 'green', 'cyan',
110
- 'blue', 'pink', 'orange', 'purple',
111
- 'gray', 'white', 'gold', 'silver',
112
- 'lightgreen', 'indigo', 'maroon', 'turquoise']
113
-
114
- for s in escore:
115
- x.append(s[1])
116
- y.append(s[4])
117
- c.append(colors[s[3]])
118
-
119
- plt.close()
120
- plt.figure(figsize=(14,5))
121
- ax=plt.axes(title=title)
122
- ax.set_facecolor('black')
123
-
124
- plt.scatter(x,y, s=10, c=c)
125
- plt.xlabel("Time in ms")
126
- plt.ylabel("MIDI Pitch")
127
 
128
  #========================================================
129
 
@@ -133,7 +110,7 @@ def render_midi(input_midi, render_as_is, extract_melody, transform):
133
  output_midi_summary = str(meta_data)
134
  output_midi = str(new_fn)
135
  output_audio = (16000, audio)
136
- output_plot = plt
137
 
138
  #========================================================
139
 
@@ -177,13 +154,12 @@ if __name__ == "__main__":
177
  )
178
  gr.Markdown("## Upload your MIDI")
179
 
180
- input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"], type="binary")
181
 
182
  gr.Markdown("## Select desired render options")
183
 
184
- render_as_is = gr.Checkbox(label="Render as-is")
185
- extract_melody = gr.Checkbox(label="Extract melody")
186
- transform = gr.Checkbox(label="Transform")
187
  submit = gr.Button()
188
 
189
  gr.Markdown("## Render results")
@@ -195,7 +171,7 @@ if __name__ == "__main__":
195
  output_plot = gr.Plot(label="Output MIDI score plot")
196
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
197
 
198
- run_event = submit.click(render_midi, [input_midi, render_as_is, extract_melody, transform],
199
  [output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
200
 
201
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)
 
28
 
29
  #==========================================================================================================
30
 
31
+ def render_midi(input_midi, render_options):
32
 
33
  print('=' * 70)
34
  print('Req start time: {:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now(PDT)))
 
101
 
102
  print('Sample INTs', escore[:5])
103
  print('=' * 70)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
 
105
  #========================================================
106
 
 
110
  output_midi_summary = str(meta_data)
111
  output_midi = str(new_fn)
112
  output_audio = (16000, audio)
113
+ output_plot = TMIDIX.plot_ms_SONG(escore)
114
 
115
  #========================================================
116
 
 
154
  )
155
  gr.Markdown("## Upload your MIDI")
156
 
157
+ input_midi = gr.File(label="Input MIDI", file_types=[".midi", ".mid", ".kar"], type="file")
158
 
159
  gr.Markdown("## Select desired render options")
160
 
161
+ render_options = gr.CheckboxGroup(["Render as-is", "Extract melody", "Transform"])
162
+
 
163
  submit = gr.Button()
164
 
165
  gr.Markdown("## Render results")
 
171
  output_plot = gr.Plot(label="Output MIDI score plot")
172
  output_midi = gr.File(label="Output MIDI file", file_types=[".mid"])
173
 
174
+ run_event = submit.click(render_midi, [input_midi, render_options],
175
  [output_midi_md5, output_midi_title, output_midi_summary, output_midi, output_audio, output_plot])
176
 
177
  app.queue(1).launch(server_port=opt.port, share=opt.share, inbrowser=True)