Spaces:
Running
Running
import secrets | |
import gradio as gr | |
from AudioFusion import Fusion | |
def process_audio(input_file, effect_8d, effect_slowed, effect_reverb, | |
pan_boundary, jump_percentage, time_l_to_r, volume_multiplier, | |
speed_multiplier, | |
room_size, damping, width, wet_level, dry_level): | |
try: | |
# Load the sound file | |
sound = Fusion.loadSound(input_file) | |
output_file = secrets.token_hex(5) | |
# Apply effects based on user choices | |
if effect_8d: | |
sound = Fusion.effect8D(sound, pan_boundary, jump_percentage, time_l_to_r, volume_multiplier) | |
if effect_slowed: | |
sound = Fusion.effectSlowed(sound, speed_multiplier) | |
if effect_reverb: | |
sound = Fusion.effectReverb(sound, room_size, damping, width, wet_level, dry_level, "temp"+output_file+".wav") | |
# Save the processed sound and return the output file | |
output = Fusion.saveSound(sound, output_file, effect_reverb, "temp"+output_file+".wav") | |
return output | |
except Fusion.InvalidMusicFileError as e: | |
return str(e) | |
except Exception as e: | |
return f"An error occurred: {str(e)}" | |
iface = gr.Interface( | |
fn=process_audio, | |
inputs=[ | |
gr.Audio(label="Upload your music file"), | |
gr.Checkbox(label="Apply 8D effect"), | |
gr.Slider(label="8D - Pan Boundary", minimum=0, maximum=100, value=50), | |
gr.Slider(label="8D - Jump Percentage", minimum=1, maximum=100, value=5), | |
gr.Slider(label="8D - Time L to R (ms)", minimum=1, value=10000), | |
gr.Checkbox(label="Apply slowed effect"), | |
gr.Slider(label="8D - Volume Multiplier", minimum=1, value=6), | |
gr.Slider(label="Slowed - Speed Multiplier", minimum=0.1, maximum=2, step=0.1, value=0.92), | |
gr.Checkbox(label="Apply reverb effect"), | |
gr.Slider(label="Reverb - Room Size", minimum=0, maximum=1, step=0.1, value=0.8), | |
gr.Slider(label="Reverb - Damping", minimum=0, maximum=10, value=1), | |
gr.Slider(label="Reverb - Width", minimum=0, maximum=1, step=0.1, value=0.5), | |
gr.Slider(label="Reverb - Wet Level", minimum=0, maximum=1, step=0.1, value=0.3), | |
gr.Slider(label="Reverb - Dry Level", minimum=0, maximum=1, step=0.1, value=0.8), | |
], | |
outputs=[gr.Audio(label="Download processed music")], | |
title="Audio Fusion" | |
) | |
iface.launch(share=False) |