xribene commited on
Commit
6f953cc
·
verified ·
1 Parent(s): 9496268

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -3,10 +3,9 @@ from pathlib import Path
3
 
4
  import librosa
5
  import torch
6
- from audiotools import AudioSignal
7
 
8
  import gradio as gr
9
- from pyharp import ModelCard, build_endpoint, save_audio
10
 
11
 
12
  def hpss(signal: AudioSignal, **kwargs):
@@ -37,7 +36,7 @@ def process_fn(audio_file_path,
37
  percussive_db: float,
38
  kernel_size: int = 31,
39
  margin: float = 1.0):
40
- sig = AudioSignal(audio_file_path)
41
 
42
  harmonic, percussive = hpss(sig, kernel_size=int(kernel_size), margin=margin)
43
 
@@ -55,17 +54,21 @@ def process_fn(audio_file_path,
55
 
56
  output_audio_path = save_audio(sig)
57
 
58
- return output_audio_path
 
 
 
59
 
60
  # Create a ModelCard
61
  card = ModelCard(
62
  name="Harmonic / Percussive Separation",
63
  description="Remix a Track into its harmonic and percussive components.",
64
  author="Hugo Flores Garcia",
65
- tags=["example", "separator", "hpss"]
 
 
66
  )
67
 
68
-
69
  # Build the endpoint
70
  with gr.Blocks() as demo:
71
  # Define your Gradio interface
@@ -100,6 +103,6 @@ with gr.Blocks() as demo:
100
  output = gr.Audio(label="Audio Output", type="filepath")
101
 
102
  # Build the endpoint
103
- widgets = build_endpoint(inputs, output, process_fn, card)
104
 
105
- demo.queue().launch(share=True)
 
3
 
4
  import librosa
5
  import torch
 
6
 
7
  import gradio as gr
8
+ from pyharp import *
9
 
10
 
11
  def hpss(signal: AudioSignal, **kwargs):
 
36
  percussive_db: float,
37
  kernel_size: int = 31,
38
  margin: float = 1.0):
39
+ sig = load_audio(audio_file_path)
40
 
41
  harmonic, percussive = hpss(sig, kernel_size=int(kernel_size), margin=margin)
42
 
 
54
 
55
  output_audio_path = save_audio(sig)
56
 
57
+ # No output labels
58
+ output_labels = LabelList()
59
+
60
+ return output_audio_path, output_labels
61
 
62
  # Create a ModelCard
63
  card = ModelCard(
64
  name="Harmonic / Percussive Separation",
65
  description="Remix a Track into its harmonic and percussive components.",
66
  author="Hugo Flores Garcia",
67
+ tags=["example", "separator", "hpss"],
68
+ midi_in=False,
69
+ midi_out=False
70
  )
71
 
 
72
  # Build the endpoint
73
  with gr.Blocks() as demo:
74
  # Define your Gradio interface
 
103
  output = gr.Audio(label="Audio Output", type="filepath")
104
 
105
  # Build the endpoint
106
+ widgets = build_endpoint(model_card, components, process_fn)
107
 
108
+ demo.queue().launch(share=True, show_error=True)