Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,29 +1,17 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
-
import sys
|
| 3 |
-
|
| 4 |
-
# Install moviepy if not installed
|
| 5 |
-
try:
|
| 6 |
-
import moviepy
|
| 7 |
-
except ImportError:
|
| 8 |
-
subprocess.check_call([sys.executable, "-m", "pip", "install", "moviepy"])
|
| 9 |
-
|
| 10 |
-
from moviepy.editor import VideoFileClip, AudioFileClip
|
| 11 |
-
import gradio as gr
|
| 12 |
-
|
| 13 |
-
|
| 14 |
import os
|
| 15 |
from random import choice
|
| 16 |
from moviepy.editor import VideoFileClip, AudioFileClip
|
| 17 |
import tempfile
|
| 18 |
import gradio as gr
|
| 19 |
|
| 20 |
-
#
|
| 21 |
-
MUSIC_DIR = "chunks" #
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
def load_music_files():
|
| 25 |
"""
|
| 26 |
-
Load all music files from the directory.
|
| 27 |
"""
|
| 28 |
try:
|
| 29 |
# Ensure directory exists and is readable
|
|
@@ -111,9 +99,4 @@ iface = gr.Interface(
|
|
| 111 |
description="Upload a video, and it will randomly select one of the uploaded or default music files to combine with the video."
|
| 112 |
)
|
| 113 |
|
| 114 |
-
# Optional: Download default music if it's not included in your Hugging Face repo
|
| 115 |
-
if not os.path.exists(DEFAULT_MUSIC):
|
| 116 |
-
print("Downloading default music...")
|
| 117 |
-
os.system('wget -O default_music.mp3 "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3"')
|
| 118 |
-
|
| 119 |
iface.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
from random import choice
|
| 3 |
from moviepy.editor import VideoFileClip, AudioFileClip
|
| 4 |
import tempfile
|
| 5 |
import gradio as gr
|
| 6 |
|
| 7 |
+
# Hugging Face repo path (update with your repo details)
|
| 8 |
+
MUSIC_DIR = "/mnt/data/chunks" # Modify this if necessary
|
| 9 |
+
|
| 10 |
+
DEFAULT_MUSIC = "/mnt/data/default_music.mp3" # Path to default music if needed
|
| 11 |
|
| 12 |
def load_music_files():
|
| 13 |
"""
|
| 14 |
+
Load all music files from the directory.
|
| 15 |
"""
|
| 16 |
try:
|
| 17 |
# Ensure directory exists and is readable
|
|
|
|
| 99 |
description="Upload a video, and it will randomly select one of the uploaded or default music files to combine with the video."
|
| 100 |
)
|
| 101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
iface.launch(debug=True)
|