marquesafonso commited on
Commit
c679ed5
·
verified ·
1 Parent(s): f2c6f1c

add waveform and bg_color params

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -6,7 +6,7 @@ import io
6
  import librosa
7
  import tempfile
8
 
9
- def extract_waveform_animation(audio_file, window_seconds=5):
10
  y, sr = librosa.load(audio_file, sr=None)
11
  duration = librosa.get_duration(y=y, sr=sr)
12
  FPS = 1
@@ -18,7 +18,8 @@ def extract_waveform_animation(audio_file, window_seconds=5):
18
  first_window = y[:window_length]
19
  x_vals = np.linspace(0, duration, num=len(y))
20
  ax.set_axis_off()
21
- fig.set_facecolor("#00FFFF00")
 
22
 
23
  def init():
24
  ax.set_xlim(0, window_seconds)
@@ -53,7 +54,9 @@ iface = gr.Interface(
53
  fn=extract_waveform_animation,
54
  inputs=[
55
  gr.Audio(type="filepath"),
56
- gr.Slider(1, 10, value=5, step=1, label="Window Size (seconds)")
 
 
57
  ],
58
  outputs=gr.Image(),
59
  description="Scroll through audio waveform with a moving window."
 
6
  import librosa
7
  import tempfile
8
 
9
+ def extract_waveform_animation(audio_file, window_seconds=5, waveform_color="blue", bg_color="#00FFFF00"):
10
  y, sr = librosa.load(audio_file, sr=None)
11
  duration = librosa.get_duration(y=y, sr=sr)
12
  FPS = 1
 
18
  first_window = y[:window_length]
19
  x_vals = np.linspace(0, duration, num=len(y))
20
  ax.set_axis_off()
21
+ ax.set_facecolor(waveform_color)
22
+ fig.set_facecolor(bg_color)
23
 
24
  def init():
25
  ax.set_xlim(0, window_seconds)
 
54
  fn=extract_waveform_animation,
55
  inputs=[
56
  gr.Audio(type="filepath"),
57
+ gr.Slider(1, 10, value=5, step=1, label="Window Size (seconds)"),
58
+ gr.ColorPicker(value="blue", label="Waveform Color"),
59
+ gr.ColorPicker(value="#00FFFF00", label="Background Color")
60
  ],
61
  outputs=gr.Image(),
62
  description="Scroll through audio waveform with a moving window."