asigalov61 commited on
Commit
a3301d2
1 Parent(s): 6fd3683

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -13
app.py CHANGED
@@ -146,7 +146,7 @@ def GenerateMIDI(progress=gr.Progress()):
146
 
147
  while itrack < len(opus):
148
  for event in opus[itrack]:
149
- if event[0] == 'note':
150
  output1.append(o)
151
  itrack += 1
152
 
@@ -156,16 +156,6 @@ def GenerateMIDI(progress=gr.Progress()):
156
 
157
  #=================================================================================================
158
 
159
- def cancel_run(output_midi_seq):
160
- if output_midi_seq is None:
161
- return None, None
162
- with open(f"Allegro-Music-Transformer-Music-Composition.mid", 'wb') as f:
163
- f.write(TMIDIX.score2midi(output_midi_seq))
164
- audio = synthesis(TMIDIX.score2opus(output_midi_seq), 'SGM-v2.01-YamahaGrand-Guit-Bass-v2.7.sf2')
165
- return "Allegro-Music-Transformer-Music-Composition.mid", (44100, audio)
166
-
167
- #=================================================================================================
168
-
169
  if __name__ == "__main__":
170
 
171
  parser = argparse.ArgumentParser()
@@ -189,13 +179,11 @@ if __name__ == "__main__":
189
  )
190
 
191
  run_btn = gr.Button("generate", variant="primary")
192
- stop_btn = gr.Button("stop and output")
193
 
194
  output_midi_seq = gr.Variable()
195
  output_midi_visualizer = gr.HTML(elem_id="midi_visualizer_container")
196
  output_audio = gr.Audio(label="output audio", format="mp3", elem_id="midi_audio")
197
  output_midi = gr.File(label="output midi", file_types=[".mid"])
198
  run_event = run_btn.click(GenerateMIDI, [], [output_midi_seq, output_midi, output_audio])
199
- stop_btn.click(cancel_run, output_midi_seq, [output_midi, output_audio], cancels=run_event, queue=False)
200
 
201
  app.queue(2).launch(server_port=opt.port, share=opt.share, inbrowser=True)
 
146
 
147
  while itrack < len(opus):
148
  for event in opus[itrack]:
149
+ if event[0] == 'note_on' or event[0] == 'note_off':
150
  output1.append(o)
151
  itrack += 1
152
 
 
156
 
157
  #=================================================================================================
158
 
 
 
 
 
 
 
 
 
 
 
159
  if __name__ == "__main__":
160
 
161
  parser = argparse.ArgumentParser()
 
179
  )
180
 
181
  run_btn = gr.Button("generate", variant="primary")
 
182
 
183
  output_midi_seq = gr.Variable()
184
  output_midi_visualizer = gr.HTML(elem_id="midi_visualizer_container")
185
  output_audio = gr.Audio(label="output audio", format="mp3", elem_id="midi_audio")
186
  output_midi = gr.File(label="output midi", file_types=[".mid"])
187
  run_event = run_btn.click(GenerateMIDI, [], [output_midi_seq, output_midi, output_audio])
 
188
 
189
  app.queue(2).launch(server_port=opt.port, share=opt.share, inbrowser=True)