File size: 2,617 Bytes
4bb640e
998beeb
9acefe3
 
 
8651489
4bb640e
 
 
8651489
19c8b69
 
4bb640e
 
 
19c8b69
 
 
4bb640e
19c8b69
 
4bb640e
19c8b69
4bb640e
 
19c8b69
4bb640e
 
19c8b69
4bb640e
19c8b69
9acefe3
 
 
 
 
 
3eb3856
4bb640e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9acefe3
3eb3856
296882b
9acefe3
 
f2728c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os
import secrets
import gradio as gr
from AudioFusion import Fusion

def process_audio(input_file,
    effect_8d, pan_boundary, jump_percentage, time_l_to_r, volume_multiplier,
    effect_slowed, speed_multiplier,
    effect_reverb, room_size, damping, width, wet_level, dry_level
):
    # Load the sound file
    sound = Fusion.loadSound(input_file)
    os.remove(os.path.abspath(input_file))
    effect_str = []
    
    # Apply effects based on user choices
    if effect_8d:
        sound = Fusion.effect8D(sound, pan_boundary, jump_percentage, time_l_to_r, volume_multiplier)
        effect_str.append("8d")
    if effect_slowed:
        sound = Fusion.effectSlowed(sound, speed_multiplier)
        effect_str.append("Slowed")
    if effect_reverb:
        sound = Fusion.effectReverb(sound, room_size, damping, width, wet_level, dry_level, "temp"+input_file+".wav")
        effect_str.append("Reverb")

    output_file = f"{input_file} {' + '.join(effects_str)} - {'By AudioFusion'}"
    
    # Save the processed sound and return the output file
    output = Fusion.saveSound(sound, output_file, effect_reverb, "temp"+input_file+".wav")
    return output



iface = gr.Interface(
    fn=process_audio,
    inputs=[
        gr.Audio(label="Upload your music file", type="filepath"),

        # 8d Effect and its arguments
        gr.Row(
            gr.Checkbox(label="Apply 8D effect"),
            gr.Slider(label="Pan Boundary", minimum=0, maximum=100, value=100),
            gr.Slider(label="Jump Percentage", minimum=1, maximum=100, value=5),
            gr.Slider(label="Time L to R (ms)", minimum=1, value=10000),
            gr.Slider(label="Volume Multiplier", minimum=1, value=6),
        ),
        
        # Slowed Effect and its arguments
        gr.Row(
            gr.Checkbox(label="Apply slowed effect"),
            gr.Slider(label="Speed Multiplier", minimum=0.1, maximum=2, step=0.1, value=0.92),
        ),
        
        # Reverb Effect and its arguments
        gr.Row(
            gr.Checkbox(label="Apply reverb effect"),
            gr.Slider(label="Room Size", minimum=0, maximum=1, step=0.1, value=0.8),
            gr.Slider(label="Damping", minimum=0, maximum=10, value=1),
            gr.Slider(label="Width", minimum=0, maximum=1, step=0.1, value=0.5),
            gr.Slider(label="Wet Level", minimum=0, maximum=1, step=0.1, value=0.3),
            gr.Slider(label="Dry Level", minimum=0, maximum=1, step=0.1, value=0.8),
        ),
    ],
    outputs=gr.Audio(label="Download processed music", type="filepath"),
    title="Audio Fusion"
)

iface.launch(share=False)