Fabrice-TIERCELIN commited on
Commit
557f1c4
·
verified ·
1 Parent(s): 2a76b54

This PR makes each generation different

Browse files

It randomizes the seed at each generation.

Click on _Merge_ to add this feature.

Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import torch
2
  import torchaudio
3
  from einops import rearrange
@@ -25,6 +26,11 @@ def load_model():
25
  def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
26
  global model, model_config
27
 
 
 
 
 
 
28
  print(f"Prompt received: {prompt}")
29
  print(f"Settings: Duration={seconds_total}s, Steps={steps}, CFG Scale={cfg_scale}")
30
 
 
1
+ import random
2
  import torch
3
  import torchaudio
4
  from einops import rearrange
 
26
  def generate_audio(prompt, seconds_total=30, steps=100, cfg_scale=7):
27
  global model, model_config
28
 
29
+ seed = random.randint(0, 2**63 - 1)
30
+ random.seed(seed)
31
+ torch.manual_seed(seed)
32
+ print(f"Using seed: {seed}")
33
+
34
  print(f"Prompt received: {prompt}")
35
  print(f"Settings: Duration={seconds_total}s, Steps={steps}, CFG Scale={cfg_scale}")
36