ambujm22 commited on
Commit
f81b71e
Β·
verified Β·
1 Parent(s): b583efa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -43,7 +43,7 @@ WEIGHTS_FILE = "model.safetensors"
43
  CACHE_DIR = SPACE_ROOT / "weights"
44
  CACHE_DIR.mkdir(parents=True, exist_ok=True)
45
 
46
- # ================ Repo clone AT STARTUP (per your request) ================
47
  def ensure_repo() -> Path:
48
  if not REPO_DIR.exists():
49
  subprocess.run(
@@ -109,6 +109,9 @@ def run_sonicmaster_cli(
109
  progress: Optional[gr.Progress] = None,
110
  ) -> Tuple[bool, str]:
111
  """Run inference via subprocess; returns (ok, message). Uses ONLY infer_single.py."""
 
 
 
112
  if progress: progress(0.14, desc="Preparing inference")
113
  ckpt = get_weights_path(progress=progress)
114
 
@@ -190,8 +193,11 @@ def enhance_audio_ui(
190
  Returns (audio, message). On failure, audio=None and message=error text.
191
  """
192
  try:
 
 
193
  if not prompt:
194
- raise gr.Error("Please provide a text prompt.")
 
195
  if not audio_path:
196
  raise gr.Error("Please upload or select an input audio file.")
197
 
@@ -229,13 +235,14 @@ def enhance_audio_ui(
229
  with gr.Blocks(title="SonicMaster – Text-Guided Restoration & Mastering", fill_height=True) as _demo:
230
  gr.Markdown(
231
  "## 🎧 SonicMaster\n"
232
- "Upload audio or pick an example, write a prompt, then click **Enhance**.\n"
 
233
  "- First run downloads model weights (progress will show).\n"
234
  )
235
  with gr.Row():
236
  with gr.Column(scale=1):
237
  in_audio = gr.Audio(label="Input Audio", type="filepath")
238
- prompt = gr.Textbox(label="Text Prompt", placeholder="e.g., Reduce reverb and brighten vocals.")
239
  run_btn = gr.Button("πŸš€ Enhance", variant="primary")
240
 
241
  # Show 10 audio+prompt examples immediately at startup
@@ -266,4 +273,4 @@ app = demo
266
 
267
  # Local debugging only
268
  if __name__ == "__main__":
269
- demo.launch(server_name="0.0.0.0", server_port=7860)
 
43
  CACHE_DIR = SPACE_ROOT / "weights"
44
  CACHE_DIR.mkdir(parents=True, exist_ok=True)
45
 
46
+ # ================ Repo clone AT STARTUP (so examples show immediately) ================
47
  def ensure_repo() -> Path:
48
  if not REPO_DIR.exists():
49
  subprocess.run(
 
109
  progress: Optional[gr.Progress] = None,
110
  ) -> Tuple[bool, str]:
111
  """Run inference via subprocess; returns (ok, message). Uses ONLY infer_single.py."""
112
+ # πŸ”§ Ensure a non-empty prompt for the CLI
113
+ prompt = (prompt or "").strip() or "Enhance the input audio"
114
+
115
  if progress: progress(0.14, desc="Preparing inference")
116
  ckpt = get_weights_path(progress=progress)
117
 
 
193
  Returns (audio, message). On failure, audio=None and message=error text.
194
  """
195
  try:
196
+ # πŸ”§ normalize/fallback so --prompt is always passed
197
+ prompt = (prompt or "").strip()
198
  if not prompt:
199
+ prompt = "Enhance the input audio"
200
+
201
  if not audio_path:
202
  raise gr.Error("Please upload or select an input audio file.")
203
 
 
235
  with gr.Blocks(title="SonicMaster – Text-Guided Restoration & Mastering", fill_height=True) as _demo:
236
  gr.Markdown(
237
  "## 🎧 SonicMaster\n"
238
+ "Upload audio or pick an example, write a prompt (or leave blank), then click **Enhance**.\n"
239
+ "If left blank, we'll use a generic prompt: _Enhance the input audio_.\n"
240
  "- First run downloads model weights (progress will show).\n"
241
  )
242
  with gr.Row():
243
  with gr.Column(scale=1):
244
  in_audio = gr.Audio(label="Input Audio", type="filepath")
245
+ prompt = gr.Textbox(label="Text Prompt", placeholder="e.g., Reduce reverb and brighten vocals. (Optional)")
246
  run_btn = gr.Button("πŸš€ Enhance", variant="primary")
247
 
248
  # Show 10 audio+prompt examples immediately at startup
 
273
 
274
  # Local debugging only
275
  if __name__ == "__main__":
276
+ demo.launch(server_name="0.0.0.0", server_port=7860)