harp-dev commited on
Commit
fd01067
·
verified ·
1 Parent(s): fb9bd6b

Check inputs before reserving the GPU, and reserve 120 s rather than 180.

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -50,7 +50,6 @@ def _audio_duration(path: str | None) -> float:
50
  return duration
51
 
52
 
53
- @spaces.GPU(duration=180)
54
  def process_fn(
55
  audio_path: str | None,
56
  prompt: str,
@@ -61,6 +60,8 @@ def process_fn(
61
  strength: float,
62
  seed: int,
63
  ) -> str:
 
 
64
  duration = _audio_duration(audio_path)
65
  prompt = (prompt or "").strip()
66
  if not prompt:
@@ -74,6 +75,14 @@ def process_fn(
74
  "with the end after the start."
75
  )
76
 
 
 
 
 
 
 
 
 
77
  try:
78
  return edit_audio(
79
  audio_path=audio_path,
 
50
  return duration
51
 
52
 
 
53
  def process_fn(
54
  audio_path: str | None,
55
  prompt: str,
 
60
  strength: float,
61
  seed: int,
62
  ) -> str:
63
+ # Checked before the GPU is reserved, so a request the model cannot take spends none of the
64
+ # caller's ZeroGPU allowance
65
  duration = _audio_duration(audio_path)
66
  prompt = (prompt or "").strip()
67
  if not prompt:
 
75
  "with the end after the start."
76
  )
77
 
78
+ return run_edit(audio_path, prompt, mode, edit_start, edit_end, continuation_length,
79
+ strength, seed)
80
+
81
+
82
+ # A 6 s restyle measured about 24 s, and inputs are capped at 30 s
83
+ @spaces.GPU(duration=120)
84
+ def run_edit(audio_path, prompt, mode, edit_start, edit_end, continuation_length, strength,
85
+ seed) -> str:
86
  try:
87
  return edit_audio(
88
  audio_path=audio_path,