Update predict.py
Browse files- predict.py +13 -13
predict.py
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
import subprocess
|
2 |
-
from cog import BasePredictor, Input, Path
|
3 |
import gradio as gr
|
4 |
import tempfile
|
|
|
5 |
|
6 |
-
class Predictor
|
7 |
def predict(self,
|
8 |
-
audio:
|
9 |
-
bg_color: str =
|
10 |
-
fg_alpha: float =
|
11 |
-
bars_color: str =
|
12 |
-
bar_count: int =
|
13 |
-
bar_width: float =
|
14 |
-
caption_text: str =
|
15 |
-
) ->
|
16 |
"""Make waveform video from audio file"""
|
17 |
waveform_video = gr.make_waveform(
|
18 |
-
|
19 |
bg_color=bg_color,
|
20 |
fg_alpha=fg_alpha,
|
21 |
bars_color=bars_color,
|
@@ -24,7 +24,7 @@ class Predictor(BasePredictor):
|
|
24 |
)
|
25 |
|
26 |
if caption_text == "" or caption_text is None:
|
27 |
-
return
|
28 |
else:
|
29 |
padded_waveform_path = tempfile.mktemp(suffix=".mp4")
|
30 |
background_image_path = tempfile.mktemp(suffix=".png")
|
@@ -50,7 +50,7 @@ class Predictor(BasePredictor):
|
|
50 |
'-filter_complex', 'overlay=0:0', final_video_path
|
51 |
], check=True)
|
52 |
|
53 |
-
return
|
54 |
|
55 |
# Gradio user interface
|
56 |
def gradio_predict(audio, bg_color, fg_alpha, bars_color, bar_count, bar_width, caption_text):
|
|
|
1 |
import subprocess
|
|
|
2 |
import gradio as gr
|
3 |
import tempfile
|
4 |
+
from pathlib import Path
|
5 |
|
6 |
+
class Predictor:
|
7 |
def predict(self,
|
8 |
+
audio: str,
|
9 |
+
bg_color: str = "#000000",
|
10 |
+
fg_alpha: float = 0.75,
|
11 |
+
bars_color: str = "#ffffff",
|
12 |
+
bar_count: int = 100,
|
13 |
+
bar_width: float = 0.4,
|
14 |
+
caption_text: str = "",
|
15 |
+
) -> str:
|
16 |
"""Make waveform video from audio file"""
|
17 |
waveform_video = gr.make_waveform(
|
18 |
+
audio,
|
19 |
bg_color=bg_color,
|
20 |
fg_alpha=fg_alpha,
|
21 |
bars_color=bars_color,
|
|
|
24 |
)
|
25 |
|
26 |
if caption_text == "" or caption_text is None:
|
27 |
+
return waveform_video
|
28 |
else:
|
29 |
padded_waveform_path = tempfile.mktemp(suffix=".mp4")
|
30 |
background_image_path = tempfile.mktemp(suffix=".png")
|
|
|
50 |
'-filter_complex', 'overlay=0:0', final_video_path
|
51 |
], check=True)
|
52 |
|
53 |
+
return final_video_path
|
54 |
|
55 |
# Gradio user interface
|
56 |
def gradio_predict(audio, bg_color, fg_alpha, bars_color, bar_count, bar_width, caption_text):
|