zarox commited on
Commit
19c8b69
·
1 Parent(s): 8651489
Files changed (1) hide show
  1. app.py +31 -35
app.py CHANGED
@@ -3,50 +3,46 @@ 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
- try:
12
- # Load the sound file
13
- # sound = Fusion.loadSound(input_file)
14
- # output_file = secrets.token_hex(5)
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
- # if effect_slowed:
20
- # sound = Fusion.effectSlowed(sound, speed_multiplier)
21
- # if effect_reverb:
22
- # sound = Fusion.effectReverb(sound, room_size, damping, width, wet_level, dry_level, "temp"+output_file+".wav")
 
 
 
 
23
 
24
- # # Save the processed sound and return the output file
25
- # output = Fusion.saveSound(sound, output_file, effect_reverb, "temp"+output_file+".wav")
26
- return input_file
27
 
28
- except Fusion.InvalidMusicFileError as e:
29
- return str(e)
30
- except Exception as e:
31
- return f"An error occurred: {str(e)}"
32
 
33
  iface = gr.Interface(
34
  fn=process_audio,
35
  inputs=[
36
  gr.Audio(label="Upload your music file"),
37
- # gr.Checkbox(label="Apply 8D effect"),
38
- # gr.Slider(label="8D - Pan Boundary", minimum=0, maximum=100, value=50),
39
- # gr.Slider(label="8D - Jump Percentage", minimum=1, maximum=100, value=5),
40
- # gr.Slider(label="8D - Time L to R (ms)", minimum=1, value=10000),
41
- # gr.Checkbox(label="Apply slowed effect"),
42
- # gr.Slider(label="8D - Volume Multiplier", minimum=1, value=6),
43
- # gr.Slider(label="Slowed - Speed Multiplier", minimum=0.1, maximum=2, step=0.1, value=0.92),
44
- # gr.Checkbox(label="Apply reverb effect"),
45
- # gr.Slider(label="Reverb - Room Size", minimum=0, maximum=1, step=0.1, value=0.8),
46
- # gr.Slider(label="Reverb - Damping", minimum=0, maximum=10, value=1),
47
- # gr.Slider(label="Reverb - Width", minimum=0, maximum=1, step=0.1, value=0.5),
48
- # gr.Slider(label="Reverb - Wet Level", minimum=0, maximum=1, step=0.1, value=0.3),
49
- # gr.Slider(label="Reverb - Dry Level", minimum=0, maximum=1, step=0.1, value=0.8),
50
  ],
51
  outputs=gr.Audio(label="Download processed music"),
52
  title="Audio Fusion"
 
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
 
 
 
 
 
28
 
29
  iface = gr.Interface(
30
  fn=process_audio,
31
  inputs=[
32
  gr.Audio(label="Upload your music file"),
33
+ gr.Checkbox(label="Apply 8D effect"),
34
+ gr.Slider(label="8D - Pan Boundary", minimum=0, maximum=100, value=50),
35
+ gr.Slider(label="8D - Jump Percentage", minimum=1, maximum=100, value=5),
36
+ gr.Slider(label="8D - Time L to R (ms)", minimum=1, value=10000),
37
+ gr.Checkbox(label="Apply slowed effect"),
38
+ gr.Slider(label="8D - Volume Multiplier", minimum=1, value=6),
39
+ gr.Slider(label="Slowed - Speed Multiplier", minimum=0.1, maximum=2, step=0.1, value=0.92),
40
+ gr.Checkbox(label="Apply reverb effect"),
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"),
48
  title="Audio Fusion"