artificialguybr commited on
Commit
85353b7
1 Parent(s): a17cbc4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -20,8 +20,9 @@ def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
20
  if not hf_token:
21
  raise EnvironmentError("HF_TOKEN environment variable not set")
22
 
23
- # Download and set up the model
24
- model, model_config = get_pretrained_model("stabilityai/stable-audio-open-1.0", use_auth_token=hf_token)
 
25
  sample_rate = model_config["sample_rate"]
26
  sample_size = model_config["sample_size"]
27
 
@@ -52,7 +53,7 @@ def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
52
 
53
  # Peak normalize, clip, convert to int16
54
  output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
55
-
56
  # Generate a unique filename for the output
57
  unique_filename = f"output_{uuid.uuid4().hex}.wav"
58
  # Save to file
 
20
  if not hf_token:
21
  raise EnvironmentError("HF_TOKEN environment variable not set")
22
 
23
+ # Login to Hugging Face before downloading the model (using torch.hub)
24
+ torch.hub._validate_not_a_forked_repo = lambda a, b, c: True
25
+ model, model_config = get_pretrained_model("stabilityai/stable-audio-open-1.0")
26
  sample_rate = model_config["sample_rate"]
27
  sample_size = model_config["sample_size"]
28
 
 
53
 
54
  # Peak normalize, clip, convert to int16
55
  output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
56
+
57
  # Generate a unique filename for the output
58
  unique_filename = f"output_{uuid.uuid4().hex}.wav"
59
  # Save to file