zarox commited on
Commit
4bb640e
·
1 Parent(s): f0eae45
Files changed (1) hide show
  1. app.py +39 -21
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, effect_slowed, effect_reverb,
7
- pan_boundary, jump_percentage, time_l_to_r, volume_multiplier,
8
- speed_multiplier,
9
- room_size, damping, width, wet_level, dry_level
10
  ):
11
  # Load the sound file
12
  sound = Fusion.loadSound(input_file)
13
- output_file = secrets.token_hex(5)
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"+output_file+".wav")
 
22
 
 
 
23
  # Save the processed sound and return the output file
24
- output = Fusion.saveSound(sound, output_file, effect_reverb, "temp"+output_file+".wav")
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
- gr.Checkbox(label="Apply 8D effect"),
34
- gr.Checkbox(label="Apply slowed effect"),
35
- gr.Checkbox(label="Apply reverb effect"),
36
- gr.Slider(label="8D - Pan Boundary", minimum=0, maximum=100, value=100),
37
- gr.Slider(label="8D - Jump Percentage", minimum=1, maximum=100, value=5),
38
- gr.Slider(label="8D - Time L to R (ms)", minimum=1, value=10000),
39
- gr.Slider(label="8D - Volume Multiplier", minimum=1, value=6),
40
- gr.Slider(label="Slowed - Speed Multiplier", minimum=0.1, maximum=2, step=0.1, value=0.92),
41
- gr.Slider(label="Reverb - Room Size", minimum=0, maximum=1, step=0.1, value=0.8),
42
- gr.Slider(label="Reverb - Damping", minimum=0, maximum=10, value=1),
43
- gr.Slider(label="Reverb - Width", minimum=0, maximum=1, step=0.1, value=0.5),
44
- gr.Slider(label="Reverb - Wet Level", minimum=0, maximum=1, step=0.1, value=0.3),
45
- gr.Slider(label="Reverb - Dry Level", minimum=0, maximum=1, step=0.1, value=0.8),
 
 
 
 
 
 
 
 
 
 
 
 
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"