tianhk commited on
Commit
f6b63b7
·
1 Parent(s): 58f4564

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -14
app.py CHANGED
@@ -24,20 +24,12 @@ def midi_ddsp_synth(instrument, midi_file):
24
  if instrument not in INST_NAME_LIST:
25
  raise ValueError('Error: not an available instrument type')
26
  instrument_id = INST_NAME_TO_ID_DICT[instrument]
27
- # sample_rate = 16000
28
- midi_audio, midi_control_params, midi_synth_params, conditioning_df = synthesize_mono_midi(synthesis_generator, expression_generator, midi_file.name, instrument_id, output_dir='./', pitch_offset=0, speed_rate=1)
29
- # x = midi_audio[0].numpy()
30
- print(os.path.join('./', os.path.basename(midi_file.name).replace('.mid', '.wav')))
31
- print(midi_file.name[:-4]+'.wav')
32
- print(os.path.abspath(os.path.join('./', os.path.basename(midi_file.name).replace('.mid', '.wav'))))
33
- return os.path.join('./', os.path.basename(midi_file.name).replace('.mid', '.wav'))
34
-
35
- # def inference(audio):
36
- # os.system("midi_ddsp_synthesize --midi_path "+audio.name)
37
- # return Path(audio.name).stem+"/0_violin.wav"
38
 
39
- # title = "Midi-DDSP"
40
- # description = "Gradio demo for MIDI-DDSP: Detailed Control of Musical Performance via Hierarchical Modeling. To use it, simply upload your midi file, or click one of the examples to load them. Read more at the links below."
41
 
42
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2112.09312' target='_blank'>MIDI-DDSP: Detailed Control of Musical Performance via Hierarchical Modeling</a> | <a href='https://github.com/magenta/midi-ddsp' target='_blank'>Github Repo</a></p>"
43
 
@@ -45,9 +37,11 @@ gr.Interface(
45
  fn = midi_ddsp_synth,
46
  inputs = [
47
  gr.inputs.Textbox(
48
- lines=1, placeholder=None, default='', label='instrument name'),
49
  gr.File(type="file", label="Input")
50
  ],
51
  outputs = "audio",
 
 
52
  article = article,
53
  ).launch(debug=True)
 
24
  if instrument not in INST_NAME_LIST:
25
  raise ValueError('Error: not an available instrument type')
26
  instrument_id = INST_NAME_TO_ID_DICT[instrument]
27
+ _ = synthesize_mono_midi(synthesis_generator, expression_generator, midi_file.name,
28
+ instrument_id, output_dir='/tmp', pitch_offset=0, speed_rate=1)
29
+ return os.path.join('/tmp', os.path.basename(midi_file.name).replace('.mid', '.wav'))
 
 
 
 
 
 
 
 
30
 
31
+ title = "Midi-DDSP"
32
+ description = "Unofficial Gradio demo for MIDI-DDSP"
33
 
34
  article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2112.09312' target='_blank'>MIDI-DDSP: Detailed Control of Musical Performance via Hierarchical Modeling</a> | <a href='https://github.com/magenta/midi-ddsp' target='_blank'>Github Repo</a></p>"
35
 
 
37
  fn = midi_ddsp_synth,
38
  inputs = [
39
  gr.inputs.Textbox(
40
+ lines=1, placeholder=None, default='', label='instrument'),
41
  gr.File(type="file", label="Input")
42
  ],
43
  outputs = "audio",
44
+ title = title,
45
+ description = description,
46
  article = article,
47
  ).launch(debug=True)