tianhk commited on
Commit
63dbe00
·
1 Parent(s): 681c9db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -1,6 +1,5 @@
1
- import gradio as gr
2
  import os
3
- from pathlib import Path
4
  from midi_ddsp.midi_ddsp_synthesize import load_pretrained_model
5
  from midi_ddsp.utils.midi_synthesis_utils import synthesize_mono_midi
6
  from midi_ddsp.data_handling.instrument_name_utils import INST_NAME_TO_ID_DICT, INST_NAME_LIST
@@ -11,13 +10,12 @@ synthesis_generator, expression_generator = load_pretrained_model()
11
  def midi_ddsp_synth(instrument, midi_file):
12
  '''
13
  Paras:
14
- midi_file: the directory of the midi file
15
- instrument: instrument type, choose from 'violin', 'viola', 'cello', 'double bass',
16
  'flute', 'oboe', 'clarinet', 'saxophone',
17
  'bassoon', 'trumpet', 'horn', 'trombone', 'tuba'
18
  Returns:
19
- fs: the sampling rate
20
- x: the audio data
21
  '''
22
  if not (os.path.isfile(midi_file.name) and midi_file.name[-4:] == '.mid'):
23
  raise FileNotFoundError('Error: not a valid midi file')
@@ -36,7 +34,7 @@ gr.Interface(
36
  fn = midi_ddsp_synth,
37
  inputs = [
38
  gr.inputs.Textbox(
39
- lines=1, placeholder=None, default='', label='choose instrument from: violin, viola, cello, double bass,\
40
  flute, oboe, clarinet, saxophone, bassoon, trumpet, horn, trombone, tuba'),
41
  gr.File(type="file", label="Upload .mid file here")
42
  ],
 
 
1
  import os
2
+ import gradio as gr
3
  from midi_ddsp.midi_ddsp_synthesize import load_pretrained_model
4
  from midi_ddsp.utils.midi_synthesis_utils import synthesize_mono_midi
5
  from midi_ddsp.data_handling.instrument_name_utils import INST_NAME_TO_ID_DICT, INST_NAME_LIST
 
10
  def midi_ddsp_synth(instrument, midi_file):
11
  '''
12
  Paras:
13
+ midi_file: the directory of the midi file
14
+ instrument: instrument type, choose from 'violin', 'viola', 'cello', 'double bass',
15
  'flute', 'oboe', 'clarinet', 'saxophone',
16
  'bassoon', 'trumpet', 'horn', 'trombone', 'tuba'
17
  Returns:
18
+ output_file_path: path of the output wav file
 
19
  '''
20
  if not (os.path.isfile(midi_file.name) and midi_file.name[-4:] == '.mid'):
21
  raise FileNotFoundError('Error: not a valid midi file')
 
34
  fn = midi_ddsp_synth,
35
  inputs = [
36
  gr.inputs.Textbox(
37
+ lines=1, placeholder=None, default='', label='Input instrument type, choose from: violin, viola, cello, double bass,\
38
  flute, oboe, clarinet, saxophone, bassoon, trumpet, horn, trombone, tuba'),
39
  gr.File(type="file", label="Upload .mid file here")
40
  ],