Allow the user to set or randomize the seed

#2
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -20,8 +20,9 @@ def load_model():
20
 
21
  # Function to set up, generate, and process the audio
22
  @spaces.GPU(duration=120) # Allocate GPU only when this function is called
23
- def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
24
- seed = random.randint(0, 2**63 - 1)
 
25
  random.seed(seed)
26
  torch.manual_seed(seed)
27
 
@@ -94,7 +95,9 @@ interface = gr.Interface(
94
  gr.Textbox(label="Prompt", placeholder="Enter your text prompt here"),
95
  gr.Slider(0, 47, value=30, label="Duration in Seconds"),
96
  gr.Slider(10, 150, value=100, step=10, label="Number of Diffusion Steps"),
97
- gr.Slider(1, 15, value=7, step=0.1, label="CFG Scale")
 
 
98
  ],
99
  outputs=gr.Audio(type="filepath", label="Generated Audio"),
100
  title="Stable Audio Generator",
 
20
 
21
  # Function to set up, generate, and process the audio
22
  @spaces.GPU(duration=120) # Allocate GPU only when this function is called
23
+ def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7, randomize_seed=True, seed=123):
24
+ if randomize_seed:
25
+ seed = random.randint(0, 2**63 - 1)
26
  random.seed(seed)
27
  torch.manual_seed(seed)
28
 
 
95
  gr.Textbox(label="Prompt", placeholder="Enter your text prompt here"),
96
  gr.Slider(0, 47, value=30, label="Duration in Seconds"),
97
  gr.Slider(10, 150, value=100, step=10, label="Number of Diffusion Steps"),
98
+ gr.Slider(1, 15, value=7, step=0.1, label="CFG Scale"),
99
+ gr.Checkbox(label = "Randomize seed", value = True, info = "If checked, result is always different"),
100
+ gr.Slider(label="Seed", minimum=0, maximum=2147483647, step=1, randomize=True)
101
  ],
102
  outputs=gr.Audio(type="filepath", label="Generated Audio"),
103
  title="Stable Audio Generator",