psistolar commited on
Commit
7e691d1
1 Parent(s): 1f0a89c

Test midi input label and start building sonification method.

Browse files
Files changed (1) hide show
  1. app.py +14 -2
app.py CHANGED
@@ -46,15 +46,27 @@ learner = music_model_learner(
46
  print("Ready to use.")
47
 
48
 
 
 
 
 
49
 
50
  def process_midi(MIDI_File, Text_to_Sonify, Randomness, Amount_of_Music_to_Add):
51
  if MIDI_File is not None:
52
  name = Path(MIDI_File.name)
53
  else:
54
  name = Path('C Major Scale.midi')
 
 
 
 
 
55
 
56
  # create the model input object
57
- item = MusicItem.from_file(name, data.vocab)
 
 
 
58
 
59
  # full is the prediction appended to the input
60
  temp = Randomness / 100
@@ -81,7 +93,7 @@ def process_midi(MIDI_File, Text_to_Sonify, Randomness, Amount_of_Music_to_Add):
81
  iface = gr.Interface(
82
  fn=process_midi,
83
  inputs=[
84
- gr.inputs.File(optional=True),
85
  "text",
86
  gr.inputs.Slider(0, 250, default=100, step=50),
87
  gr.inputs.Radio([100, 200, 500], type="value", default=100)
 
46
  print("Ready to use.")
47
 
48
 
49
+ def sonify_text(text):
50
+ name = Path('C Major Scale.midi')
51
+ item = MusicItem.from_file(name, data.vocab)
52
+ return item
53
 
54
  def process_midi(MIDI_File, Text_to_Sonify, Randomness, Amount_of_Music_to_Add):
55
  if MIDI_File is not None:
56
  name = Path(MIDI_File.name)
57
  else:
58
  name = Path('C Major Scale.midi')
59
+
60
+ sonification = False
61
+ if MIDI_File is None and Text_to_Sonify is not None:
62
+ sonification = True
63
+
64
 
65
  # create the model input object
66
+ if sonification:
67
+ item = sonify_text(Text_to_Sonify)
68
+ else:
69
+ item = MusicItem.from_file(name, data.vocab)
70
 
71
  # full is the prediction appended to the input
72
  temp = Randomness / 100
 
93
  iface = gr.Interface(
94
  fn=process_midi,
95
  inputs=[
96
+ gr.inputs.File(optional=True, label="Upload your own MIDI file here."),
97
  "text",
98
  gr.inputs.Slider(0, 250, default=100, step=50),
99
  gr.inputs.Radio([100, 200, 500], type="value", default=100)