AudioMix / app.py
atz21's picture
Update app.py
306f985 verified
import gradio as gr
from pydub import AudioSegment
def combine_audio(waves_file, seagulls_file):
try:
# Load the audio files
waves = AudioSegment.from_file(waves_file)
seagulls = AudioSegment.from_file(seagulls_file)
# Adjust volumes
waves = waves - 5 # Lower the volume of waves by 5dB
seagulls = seagulls + 3 # Increase the volume of seagulls by 3dB
# Combine audio
combined_audio = waves.overlay(seagulls)
# Save the output
output_file = "seagulls_over_waves.mp3"
combined_audio.export(output_file, format="mp3")
return output_file
except Exception as e:
return f"Error: {e}"
# Define the Gradio interface
interface = gr.Interface(
fn=combine_audio,
inputs=[
gr.Audio(type="filepath", label="Upload Audio"),
gr.Audio(type="filepath", label="Upload Audio"),
],
outputs=gr.Audio(type="filepath", label="Combined Audio"),
title="AudioMix_v1",
description="Upload two audio files (e.g., waves and seagulls) to combine them into one seamless track.",
)
# Launch the app
if __name__ == "__main__":
interface.launch()