Spaces:
Running
Running
Commit
·
800ebaa
1
Parent(s):
0810ae7
return to original demo
Browse files- Dockerfile +1 -1
- app.py +19 -55
Dockerfile
CHANGED
@@ -9,7 +9,7 @@ RUN apt-get update && apt-get install -y \
|
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
# Install pip packages
|
12 |
-
RUN pip install gradio==3.50.2
|
13 |
|
14 |
# Set environment variables for matplotlib and fontconfig
|
15 |
ENV MPLCONFIGDIR=/tmp/matplotlib
|
|
|
9 |
&& rm -rf /var/lib/apt/lists/*
|
10 |
|
11 |
# Install pip packages
|
12 |
+
RUN pip install gradio==3.50.2
|
13 |
|
14 |
# Set environment variables for matplotlib and fontconfig
|
15 |
ENV MPLCONFIGDIR=/tmp/matplotlib
|
app.py
CHANGED
@@ -3,17 +3,6 @@ import gradio as gr
|
|
3 |
import tempfile
|
4 |
from pathlib import Path
|
5 |
import os
|
6 |
-
from moviepy.editor import VideoFileClip
|
7 |
-
|
8 |
-
def convert_video_to_audio(video_input):
|
9 |
-
video_clip = VideoFileClip(video_input)
|
10 |
-
audio_clip = video_clip.audio
|
11 |
-
audio_clip_filepath = os.path.normpath(f"{video_input.split('.')[0]}.m4a")
|
12 |
-
audio_clip.write_audiofile(audio_clip_filepath, codec='aac')
|
13 |
-
audio_clip.close()
|
14 |
-
video_clip.close()
|
15 |
-
return audio_clip_filepath
|
16 |
-
|
17 |
|
18 |
# Check permissions and environment setup
|
19 |
print("Checking directory and file permissions...")
|
@@ -73,12 +62,8 @@ class Predictor:
|
|
73 |
return final_video_path
|
74 |
|
75 |
# Gradio user interface
|
76 |
-
def gradio_predict(
|
77 |
predictor = Predictor()
|
78 |
-
if input_obj_type =="video":
|
79 |
-
audio = convert_video_to_audio(video_input=input_obj)
|
80 |
-
else:
|
81 |
-
audio = input_obj
|
82 |
result = predictor.predict(
|
83 |
audio=audio,
|
84 |
bg_color=bg_color,
|
@@ -90,44 +75,23 @@ def gradio_predict(input_obj, input_obj_type, bg_color, fg_alpha, bars_color, ba
|
|
90 |
)
|
91 |
return result
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
outputs=gr.Video(label="Waveform Video"),
|
110 |
-
live=False,
|
111 |
-
allow_flagging="never"
|
112 |
-
)
|
113 |
-
with gr.Tab("Audio", id="audio"):
|
114 |
-
gr.Interface(
|
115 |
-
fn=gradio_predict,
|
116 |
-
inputs=[
|
117 |
-
gr.Audio(source="upload", type="filepath", label="Audio File"),
|
118 |
-
gr.Radio(choices=["audio"], value="audio", label="File Type"),
|
119 |
-
gr.Textbox(value="#000000", label="Background Color"),
|
120 |
-
gr.Slider(0, 1, value=0.75, label="Foreground Opacity"),
|
121 |
-
gr.ColorPicker(value="#ffffff", label="Bars Color"),
|
122 |
-
gr.Slider(10, 500, value=100, step=1, label="Number of Bars"),
|
123 |
-
gr.Slider(0, 1, value=0.4, step=0.1, label="Bar Width"),
|
124 |
-
gr.Textbox(value="", label="Caption Text")
|
125 |
-
],
|
126 |
-
outputs=gr.Video(label="Waveform Video"),
|
127 |
-
live=False,
|
128 |
-
allow_flagging="never"
|
129 |
-
)
|
130 |
-
demo.launch()
|
131 |
|
132 |
if __name__ == "__main__":
|
133 |
-
|
|
|
|
3 |
import tempfile
|
4 |
from pathlib import Path
|
5 |
import os
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
# Check permissions and environment setup
|
8 |
print("Checking directory and file permissions...")
|
|
|
62 |
return final_video_path
|
63 |
|
64 |
# Gradio user interface
|
65 |
+
def gradio_predict(audio, bg_color, fg_alpha, bars_color, bar_count, bar_width, caption_text):
|
66 |
predictor = Predictor()
|
|
|
|
|
|
|
|
|
67 |
result = predictor.predict(
|
68 |
audio=audio,
|
69 |
bg_color=bg_color,
|
|
|
75 |
)
|
76 |
return result
|
77 |
|
78 |
+
# Launch Gradio interface
|
79 |
+
interface = gr.Interface(
|
80 |
+
fn=gradio_predict,
|
81 |
+
inputs=[
|
82 |
+
gr.Audio(source="upload", type="filepath", label="Audio File"),
|
83 |
+
gr.Textbox(value="#000000", label="Background Color"),
|
84 |
+
gr.Slider(0, 1, value=0.75, label="Foreground Opacity"),
|
85 |
+
gr.ColorPicker(value="#ffffff", label="Bars Color"),
|
86 |
+
gr.Slider(10, 500, value=100, step=1, label="Number of Bars"),
|
87 |
+
gr.Slider(0, 1, value=0.4, step=0.1, label="Bar Width"),
|
88 |
+
gr.Textbox(value="", label="Caption Text")
|
89 |
+
],
|
90 |
+
outputs=gr.Video(label="Waveform Video"),
|
91 |
+
live=False,
|
92 |
+
allow_flagging="never"
|
93 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
if __name__ == "__main__":
|
96 |
+
print("Starting Gradio interface...")
|
97 |
+
interface.launch(server_name="0.0.0.0", server_port=7860)
|