Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,40 +3,27 @@ import subprocess
|
|
| 3 |
subprocess.run(["pip", "install", "-r", "requirements.txt"])
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
-
import librosa
|
| 7 |
-
import numpy as np
|
| 8 |
from pydub import AudioSegment
|
| 9 |
|
| 10 |
-
# Function to synchronize vocal and beat
|
| 11 |
def synchronize_audio(vocal_file, beat_file):
|
| 12 |
-
# Load audio files
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
beat_resized = librosa.effects.trim(beat_audio, duration=beat_duration)[0]
|
| 22 |
|
| 23 |
-
|
| 24 |
-
synchronized_audio = vocal_array + beat_resized
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
# Gradio Interface
|
| 29 |
iface = gr.Interface(
|
| 30 |
-
|
| 31 |
-
inputs=[
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
],
|
| 35 |
-
outputs="audio",
|
| 36 |
-
live=True,
|
| 37 |
-
title="Audio Synchronization",
|
| 38 |
-
description="Upload a vocal file and a beat to synchronize them.",
|
| 39 |
)
|
| 40 |
|
| 41 |
-
# Launch Gradio interface
|
| 42 |
iface.launch()
|
|
|
|
| 3 |
subprocess.run(["pip", "install", "-r", "requirements.txt"])
|
| 4 |
|
| 5 |
import gradio as gr
|
|
|
|
|
|
|
| 6 |
from pydub import AudioSegment
|
| 7 |
|
|
|
|
| 8 |
def synchronize_audio(vocal_file, beat_file):
|
| 9 |
+
# Load the audio files
|
| 10 |
+
vocal = AudioSegment.from_file(vocal_file)
|
| 11 |
+
beat = AudioSegment.from_file(beat_file)
|
| 12 |
|
| 13 |
+
# Synchronize the audio tracks
|
| 14 |
+
synchronized_audio = vocal.overlay(beat)
|
| 15 |
|
| 16 |
+
# Export the synchronized audio
|
| 17 |
+
synchronized_audio.export("output_synchronized_audio.mp3", format="mp3")
|
|
|
|
| 18 |
|
| 19 |
+
return "Audio synchronization completed. You can download the synchronized audio."
|
|
|
|
| 20 |
|
| 21 |
+
# Gradio interface
|
|
|
|
|
|
|
| 22 |
iface = gr.Interface(
|
| 23 |
+
synchronize_audio,
|
| 24 |
+
inputs=[gr.File("Vocal File"), gr.File("Beat File")],
|
| 25 |
+
outputs=gr.Textbox(),
|
| 26 |
+
live=True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
)
|
| 28 |
|
|
|
|
| 29 |
iface.launch()
|