2cylu2 commited on
Commit
a406960
·
verified ·
1 Parent(s): 03155f9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import matchering as mg
3
+ import tempfile
4
+ import os
5
+
6
+ from pyharp import ModelCard, build_endpoint
7
+
8
+ model_card = ModelCard(
9
+ name="Matchering 2.0",
10
+ description="Automatic audio mastering using a reference track.",
11
+ author="Matchering",
12
+ tags=["mastering", "audio", "production"]
13
+ )
14
+
15
+ def process_fn(target_path, reference_path):
16
+ try:
17
+ output_file = tempfile.NamedTemporaryFile(
18
+ delete=False, suffix=".wav"
19
+ ).name
20
+
21
+ mg.process(
22
+ target=target_path,
23
+ reference=reference_path,
24
+ results=[mg.pcm16(output_file)],
25
+ )
26
+
27
+ return output_file
28
+
29
+ except Exception as e:
30
+ print("Error:", e)
31
+ return target_path
32
+
33
+ with gr.Blocks() as demo:
34
+ input_target = gr.Audio(type="filepath", label="Target Track").harp_required(True)
35
+ input_reference = gr.Audio(type="filepath", label="Reference Track").harp_required(True)
36
+
37
+ output_audio = gr.Audio(type="filepath", label="Mastered Output")
38
+
39
+ build_endpoint(
40
+ model_card=model_card,
41
+ process_fn=process_fn,
42
+ input_components=[input_target, input_reference],
43
+ output_components=[output_audio],
44
+ )
45
+
46
+ if __name__ == "__main__":
47
+ demo.queue().launch()