imCuteCat commited on
Commit
71aad4e
1 Parent(s): d8f4957

Update predict.py

Browse files
Files changed (1) hide show
  1. 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(BasePredictor):
7
  def predict(self,
8
- audio: Path = Input(description="Audio file to create waveform from"),
9
- bg_color: str = Input(description="Background color of waveform", default="#000000"),
10
- fg_alpha: float = Input(description="Opacity of foreground waveform", default=0.75),
11
- bars_color: str = Input(description="Color of waveform bars", default="#ffffff"),
12
- bar_count: int = Input(description="Number of bars in waveform", default=100),
13
- bar_width: float = Input(description="Width of bars in waveform. 1 represents full width, 0.5 represents half width, etc.", default=0.4),
14
- caption_text: str = Input(description="Caption text for the video", default=""),
15
- ) -> Path:
16
  """Make waveform video from audio file"""
17
  waveform_video = gr.make_waveform(
18
- str(audio),
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 Path(waveform_video)
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 Path(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):
 
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):