hysts HF Staff commited on
Commit
bd8bc39
·
1 Parent(s): 7d978b4
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import pathlib
2
  import tempfile
3
 
@@ -7,6 +8,8 @@ from utils import hex_to_rgb, visualize
7
 
8
  ABOUT = "# [seewav](https://github.com/adefossez/seewav)"
9
 
 
 
10
 
11
  def run(
12
  audio_file: str,
@@ -15,7 +18,6 @@ def run(
15
  num_bars: int = 50,
16
  video_width: int = 400,
17
  video_height: int = 300,
18
- progress: gr.Progress = gr.Progress(track_tqdm=True), # noqa: ARG001, B008
19
  ) -> str:
20
  """Generates a waveform video from an audio file using the seewav tool.
21
 
@@ -29,8 +31,6 @@ def run(
29
  num_bars (int, optional): Number of bars to display in the waveform visualization. Defaults to 50.
30
  video_width (int, optional): Width of the output video in pixels. Defaults to 400.
31
  video_height (int, optional): Height of the output video in pixels. Defaults to 300.
32
- progress (gr.Progress, optional): Internal parameter for displaying progress in a Gradio interface.
33
- Not intended to be set manually by the user.
34
 
35
  Returns:
36
  str: Path to the generated waveform video file.
@@ -40,6 +40,7 @@ def run(
40
  audio_file,
41
  pathlib.Path(tmp),
42
  pathlib.Path(out.name),
 
43
  bars=num_bars,
44
  fg_color=hex_to_rgb(wave_color),
45
  bg_color=hex_to_rgb(background_color),
 
1
+ import os
2
  import pathlib
3
  import tempfile
4
 
 
8
 
9
  ABOUT = "# [seewav](https://github.com/adefossez/seewav)"
10
 
11
+ MAX_DURATION = int(os.getenv("MAX_DURATION", "0"))
12
+
13
 
14
  def run(
15
  audio_file: str,
 
18
  num_bars: int = 50,
19
  video_width: int = 400,
20
  video_height: int = 300,
 
21
  ) -> str:
22
  """Generates a waveform video from an audio file using the seewav tool.
23
 
 
31
  num_bars (int, optional): Number of bars to display in the waveform visualization. Defaults to 50.
32
  video_width (int, optional): Width of the output video in pixels. Defaults to 400.
33
  video_height (int, optional): Height of the output video in pixels. Defaults to 300.
 
 
34
 
35
  Returns:
36
  str: Path to the generated waveform video file.
 
40
  audio_file,
41
  pathlib.Path(tmp),
42
  pathlib.Path(out.name),
43
+ duration=MAX_DURATION if MAX_DURATION > 0 else None,
44
  bars=num_bars,
45
  fg_color=hex_to_rgb(wave_color),
46
  bg_color=hex_to_rgb(background_color),