ghostai1 commited on
Commit
9471eea
·
verified ·
1 Parent(s): 857db5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -13,6 +13,7 @@ from torch.cuda.amp import autocast
13
  import warnings
14
  import random
15
  from huggingface_hub import login
 
16
 
17
  # Suppress warnings for cleaner output
18
  warnings.filterwarnings("ignore")
@@ -266,10 +267,11 @@ def generate_music(instrumental_prompt: str, cfg_scale: float, top_k: int, top_p
266
  if audio_chunk.shape[0] != 2:
267
  raise ValueError(f"Expected stereo audio with shape (2, samples), got shape {audio_chunk.shape}")
268
 
269
- temp_wav_path = f"temp_chunk_{i}.wav"
270
- torchaudio.save(temp_wav_path, audio_chunk, sample_rate, bits_per_sample=24)
271
- segment = AudioSegment.from_wav(temp_wav_path)
272
- os.remove(temp_wav_path)
 
273
  audio_segments.append(segment)
274
 
275
  torch.cuda.empty_cache()
@@ -563,8 +565,6 @@ with gr.Blocks(css=css) as demo:
563
 
564
  # 9) TURN OFF OPENAPI/DOCS
565
  app = demo.launch(
566
- server_name="0.0.0.0",
567
- server_port=9999,
568
  share=False,
569
  inbrowser=False,
570
  show_error=True
 
13
  import warnings
14
  import random
15
  from huggingface_hub import login
16
+ import tempfile
17
 
18
  # Suppress warnings for cleaner output
19
  warnings.filterwarnings("ignore")
 
267
  if audio_chunk.shape[0] != 2:
268
  raise ValueError(f"Expected stereo audio with shape (2, samples), got shape {audio_chunk.shape}")
269
 
270
+ with tempfile.NamedTemporaryFile(suffix=".wav", delete=False) as temp_wav:
271
+ temp_wav_path = temp_wav.name
272
+ torchaudio.save(temp_wav_path, audio_chunk, sample_rate, bits_per_sample=24)
273
+ segment = AudioSegment.from_wav(temp_wav_path)
274
+ os.unlink(temp_wav_path)
275
  audio_segments.append(segment)
276
 
277
  torch.cuda.empty_cache()
 
565
 
566
  # 9) TURN OFF OPENAPI/DOCS
567
  app = demo.launch(
 
 
568
  share=False,
569
  inbrowser=False,
570
  show_error=True