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*1000, 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.Checkbox(label="Apply 8D effect"), # gr.Slider(label="8D - Pan Boundary", minimum=0, maximum=100, value=100), # gr.Slider(label="8D - Jump Percentage", minimum=1, maximum=100, value=5), # gr.Slider(label="8D - Time L to R (s)", minimum=1, maximum=30, value=10), # gr.Slider(label="8D - Volume Multiplier", minimum=1, maximum=20, value=6), # # SLowed Effect and its arguments # gr.Checkbox(label="Apply slowed effect"), # gr.Slider(label="Slowed - Speed Multiplier", minimum=0.1, maximum=4, step=0.01, value=0.92), # # Reverb Effect and its arguments # gr.Checkbox(label="Apply reverb effect"), # gr.Slider(label="Reverb - Room Size", minimum=0, maximum=2, step=0.01, value=0.8), # gr.Slider(label="Reverb - Damping", minimum=0, maximum=2, value=1), # gr.Slider(label="Reverb - Width", minimum=0, maximum=2, step=0.1, value=0.5), # gr.Slider(label="Reverb - Wet Level", minimum=0, maximum=2, step=0.1, value=0.3), # gr.Slider(label="Reverb - Dry Level", minimum=0, maximum=2, step=0.1, value=0.8), # ], # outputs=gr.Audio(label="Download processed music", type="filepath"), # title="Audio Fusion" # ) with gr.Blocks(title="Audio Fusion") as iface: gr.Markdown("

Audio Fusion

") input_audio = gr.Audio(label="Upload your music file", type="filepath") # 8d Effect and its arguments with gr.Tab("8d Effect"): d_check = gr.Checkbox(label="Apply 8D effect") with gr.Column(): pan = gr.Slider(label="8D - Pan Boundary", minimum=0, maximum=100, value=100) jump = gr.Slider(label="8D - Jump Percentage", minimum=1, maximum=100, value=5) time = gr.Slider(label="8D - Time L to R (s)", minimum=1, maximum=30, value=10) volx = gr.Slider(label="8D - Volume Multiplier", minimum=1, maximum=20, value=6) # SLowed Effect and its arguments with gr.Tab("Slowed Effect"): speed_check = gr.Checkbox(label="Apply slowed effect") with gr.Row(): speed = gr.Slider(label="Slowed - Speed Multiplier", minimum=0.1, maximum=4, step=0.01, value=0.92) # Reverb Effect and its arguments with gr.Tab("Reverb Effect"): reverb_check = gr.Checkbox(label="Apply reverb effect") with gr.Column(): room = gr.Slider(label="Reverb - Room Size", minimum=0, maximum=2, step=0.01, value=0.8) damp = gr.Slider(label="Reverb - Damping", minimum=0, maximum=2, value=1) width = gr.Slider(label="Reverb - Width", minimum=0, maximum=2, step=0.1, value=0.5) wet = gr.Slider(label="Reverb - Wet Level", minimum=0, maximum=2, step=0.1, value=0.3) dry = gr.Slider(label="Reverb - Dry Level", minimum=0, maximum=2, step=0.1, value=0.8) inputs = [input_audio, d_check, pan, jump, time, volx, speed_check, speed, reverb_check, room, damp, width, wet, dry] output = [gr.Audio(label="Download processed music", type="filepath")] btn = gr.Button("Run", size="sm") btn.click(fn=process_audio, inputs=inputs, outputs=output, api_name="AudioFusion") iface.launch(share=False)