yoyolicoris commited on
Commit
f2a0080
·
1 Parent(s): 587266b

feat: load example audio by default

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import gradio as gr
2
  import numpy as np
 
3
  import matplotlib.pyplot as plt
4
  import torch
5
  import math
@@ -38,6 +39,8 @@ To give you some idea, we empirically found that the first PC controls the amoun
38
  Note that adding these PCs together does not necessarily mean that their effects are additive in the final audio.
39
  We found sometimes the effects of least important PCs are more perceptible.
40
  Try to play around with the sliders and buttons and see what you can come up with!
 
 
41
  """
42
 
43
  SLIDER_MAX = 3
@@ -50,6 +53,7 @@ INFO_PATH = "presets/internal/info.json"
50
  MASK_PATH = "presets/internal/feature_mask.npy"
51
  PRESET_PATH = "presets/internal/raw_params.npy"
52
  TRAIN_INDEX_PATH = "presets/internal/train_index.npy"
 
53
 
54
 
55
  with open(CONFIG_PATH) as fp:
@@ -362,6 +366,7 @@ with gr.Blocks() as demo:
362
  z = gr.State(torch.zeros_like(mean))
363
  fx_params = gr.State(mean)
364
  fx = vec2fx(fx_params.value)
 
365
 
366
  default_pc_slider = partial(
367
  gr.Slider, minimum=SLIDER_MIN, maximum=SLIDER_MAX, interactive=True, value=0
@@ -384,7 +389,9 @@ with gr.Blocks() as demo:
384
 
385
  with gr.Row():
386
  with gr.Column():
387
- audio_input = default_audio_block(sources="upload", label="Input Audio")
 
 
388
  with gr.Row():
389
  random_button = gr.Button(
390
  f"Randomise PCs",
 
1
  import gradio as gr
2
  import numpy as np
3
+ from scipy.io.wavfile import read
4
  import matplotlib.pyplot as plt
5
  import torch
6
  import math
 
39
  Note that adding these PCs together does not necessarily mean that their effects are additive in the final audio.
40
  We found sometimes the effects of least important PCs are more perceptible.
41
  Try to play around with the sliders and buttons and see what you can come up with!
42
+
43
+ > **_Note:_** To upload your own audio, click X on the top right corner of the input audio block.
44
  """
45
 
46
  SLIDER_MAX = 3
 
53
  MASK_PATH = "presets/internal/feature_mask.npy"
54
  PRESET_PATH = "presets/internal/raw_params.npy"
55
  TRAIN_INDEX_PATH = "presets/internal/train_index.npy"
56
+ EXAMPLE_PATH = "eleanor_erased.wav"
57
 
58
 
59
  with open(CONFIG_PATH) as fp:
 
366
  z = gr.State(torch.zeros_like(mean))
367
  fx_params = gr.State(mean)
368
  fx = vec2fx(fx_params.value)
369
+ sr, y = read(EXAMPLE_PATH)
370
 
371
  default_pc_slider = partial(
372
  gr.Slider, minimum=SLIDER_MIN, maximum=SLIDER_MAX, interactive=True, value=0
 
389
 
390
  with gr.Row():
391
  with gr.Column():
392
+ audio_input = default_audio_block(
393
+ sources="upload", label="Input Audio", value=(sr, y)
394
+ )
395
  with gr.Row():
396
  random_button = gr.Button(
397
  f"Randomise PCs",