Spaces:
Running
Running
UPDATE
Browse files
app.py
CHANGED
@@ -1,27 +1,33 @@
|
|
|
|
1 |
import secrets
|
2 |
import gradio as gr
|
3 |
from AudioFusion import Fusion
|
4 |
|
5 |
def process_audio(input_file,
|
6 |
-
effect_8d,
|
7 |
-
|
8 |
-
|
9 |
-
room_size, damping, width, wet_level, dry_level
|
10 |
):
|
11 |
# Load the sound file
|
12 |
sound = Fusion.loadSound(input_file)
|
13 |
-
|
14 |
-
|
|
|
15 |
# Apply effects based on user choices
|
16 |
if effect_8d:
|
17 |
sound = Fusion.effect8D(sound, pan_boundary, jump_percentage, time_l_to_r, volume_multiplier)
|
|
|
18 |
if effect_slowed:
|
19 |
sound = Fusion.effectSlowed(sound, speed_multiplier)
|
|
|
20 |
if effect_reverb:
|
21 |
-
sound = Fusion.effectReverb(sound, room_size, damping, width, wet_level, dry_level, "temp"+
|
|
|
22 |
|
|
|
|
|
23 |
# Save the processed sound and return the output file
|
24 |
-
output = Fusion.saveSound(sound, output_file, effect_reverb, "temp"+
|
25 |
return output
|
26 |
|
27 |
|
@@ -30,19 +36,31 @@ iface = gr.Interface(
|
|
30 |
fn=process_audio,
|
31 |
inputs=[
|
32 |
gr.Audio(label="Upload your music file", type="filepath"),
|
33 |
-
|
34 |
-
|
35 |
-
gr.
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
gr.
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
],
|
47 |
outputs=gr.Audio(label="Download processed music", type="filepath"),
|
48 |
title="Audio Fusion"
|
|
|
1 |
+
import os
|
2 |
import secrets
|
3 |
import gradio as gr
|
4 |
from AudioFusion import Fusion
|
5 |
|
6 |
def process_audio(input_file,
|
7 |
+
effect_8d, pan_boundary, jump_percentage, time_l_to_r, volume_multiplier,
|
8 |
+
effect_slowed, speed_multiplier,
|
9 |
+
effect_reverb, room_size, damping, width, wet_level, dry_level
|
|
|
10 |
):
|
11 |
# Load the sound file
|
12 |
sound = Fusion.loadSound(input_file)
|
13 |
+
os.remove(os.path.abspath(input_file))
|
14 |
+
effect_str = []
|
15 |
+
|
16 |
# Apply effects based on user choices
|
17 |
if effect_8d:
|
18 |
sound = Fusion.effect8D(sound, pan_boundary, jump_percentage, time_l_to_r, volume_multiplier)
|
19 |
+
effect_str.append("8d")
|
20 |
if effect_slowed:
|
21 |
sound = Fusion.effectSlowed(sound, speed_multiplier)
|
22 |
+
effect_str.append("Slowed")
|
23 |
if effect_reverb:
|
24 |
+
sound = Fusion.effectReverb(sound, room_size, damping, width, wet_level, dry_level, "temp"+input_file+".wav")
|
25 |
+
effect_str.append("Reverb")
|
26 |
|
27 |
+
output_file = f"{input_file} {' + '.join(effects_str)} - {'By AudioFusion'}"
|
28 |
+
|
29 |
# Save the processed sound and return the output file
|
30 |
+
output = Fusion.saveSound(sound, output_file, effect_reverb, "temp"+input_file+".wav")
|
31 |
return output
|
32 |
|
33 |
|
|
|
36 |
fn=process_audio,
|
37 |
inputs=[
|
38 |
gr.Audio(label="Upload your music file", type="filepath"),
|
39 |
+
|
40 |
+
# 8d Effect and its arguments
|
41 |
+
gr.Row(
|
42 |
+
gr.Checkbox(label="Apply 8D effect"),
|
43 |
+
gr.Slider(label="Pan Boundary", minimum=0, maximum=100, value=100),
|
44 |
+
gr.Slider(label="Jump Percentage", minimum=1, maximum=100, value=5),
|
45 |
+
gr.Slider(label="Time L to R (ms)", minimum=1, value=10000),
|
46 |
+
gr.Slider(label="Volume Multiplier", minimum=1, value=6),
|
47 |
+
),
|
48 |
+
|
49 |
+
# Slowed Effect and its arguments
|
50 |
+
gr.Row(
|
51 |
+
gr.Checkbox(label="Apply slowed effect"),
|
52 |
+
gr.Slider(label="Speed Multiplier", minimum=0.1, maximum=2, step=0.1, value=0.92),
|
53 |
+
),
|
54 |
+
|
55 |
+
# Reverb Effect and its arguments
|
56 |
+
gr.Row(
|
57 |
+
gr.Checkbox(label="Apply reverb effect"),
|
58 |
+
gr.Slider(label="Room Size", minimum=0, maximum=1, step=0.1, value=0.8),
|
59 |
+
gr.Slider(label="Damping", minimum=0, maximum=10, value=1),
|
60 |
+
gr.Slider(label="Width", minimum=0, maximum=1, step=0.1, value=0.5),
|
61 |
+
gr.Slider(label="Wet Level", minimum=0, maximum=1, step=0.1, value=0.3),
|
62 |
+
gr.Slider(label="Dry Level", minimum=0, maximum=1, step=0.1, value=0.8),
|
63 |
+
),
|
64 |
],
|
65 |
outputs=gr.Audio(label="Download processed music", type="filepath"),
|
66 |
title="Audio Fusion"
|