reach-vb HF staff commited on
Commit
3918537
1 Parent(s): f04e297

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
2
  import librosa
3
  import numpy as np
4
  import torch
 
5
 
6
  from diffusers import SpectrogramDiffusionPipeline, MidiProcessor
7
 
@@ -12,6 +13,11 @@ pipe.enable_xformers_memory_efficient_attention()
12
 
13
  processor = MidiProcessor()
14
 
 
 
 
 
 
15
 
16
  def predict(audio_file_pth):
17
 
@@ -19,7 +25,7 @@ def predict(audio_file_pth):
19
  output = pipe(processor(audio_file_pth.name)[:2])
20
  audio = output.audios[0]
21
 
22
- return (16000, audio.ravel())
23
 
24
 
25
  title = "Music Spectrogram Diffusion: Multi-instrument Music Synthesis with Spectrogram Diffusion"
@@ -39,7 +45,7 @@ gr.Interface(
39
  gr.File(label="Upload MIDI", file_count="single", file_types=[".mid"]),
40
  ],
41
  outputs=[
42
- gr.Audio(label="Synthesised Music", type="numpy"),
43
  ],
44
  title=title,
45
  description=description,
 
2
  import librosa
3
  import numpy as np
4
  import torch
5
+ import random
6
 
7
  from diffusers import SpectrogramDiffusionPipeline, MidiProcessor
8
 
 
13
 
14
  processor = MidiProcessor()
15
 
16
+ COLORS = [
17
+ ["#ff0000", "#00ff00"],
18
+ ["#00ff00", "#0000ff"],
19
+ ["#0000ff", "#ff0000"],
20
+ ]
21
 
22
  def predict(audio_file_pth):
23
 
 
25
  output = pipe(processor(audio_file_pth.name)[:2])
26
  audio = output.audios[0]
27
 
28
+ return gr.make_waveform((16000, audio.ravel()), bars_color=random.choice(COLORS), bar_count=75)
29
 
30
 
31
  title = "Music Spectrogram Diffusion: Multi-instrument Music Synthesis with Spectrogram Diffusion"
 
45
  gr.File(label="Upload MIDI", file_count="single", file_types=[".mid"]),
46
  ],
47
  outputs=[
48
+ gr.Video(label="Synthesised Audio"),
49
  ],
50
  title=title,
51
  description=description,