File size: 1,181 Bytes
a0d02aa 306f985 a0d02aa e51570e d9e3610 a0d02aa | 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 | 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()
|