Spaces:
Running
Running
zhzluke96
commited on
Commit
•
b44532e
1
Parent(s):
4c19a5a
update
Browse files- modules/SynthesizeSegments.py +2 -3
- modules/utils/SeedContext.py +2 -2
- modules/utils/rng.py +5 -5
- webui.py +1 -1
modules/SynthesizeSegments.py
CHANGED
@@ -55,11 +55,10 @@ def to_number(value, t, default=0):
|
|
55 |
|
56 |
|
57 |
class SynthesizeSegments:
|
58 |
-
batch_default_spk_seed = rng.np_rng()
|
59 |
-
batch_default_infer_seed = rng.np_rng()
|
60 |
-
|
61 |
def __init__(self, batch_size: int = 8):
|
62 |
self.batch_size = batch_size
|
|
|
|
|
63 |
|
64 |
def segment_to_generate_params(self, segment: Dict[str, Any]) -> Dict[str, Any]:
|
65 |
if segment.get("params", None) is not None:
|
|
|
55 |
|
56 |
|
57 |
class SynthesizeSegments:
|
|
|
|
|
|
|
58 |
def __init__(self, batch_size: int = 8):
|
59 |
self.batch_size = batch_size
|
60 |
+
self.batch_default_spk_seed = rng.np_rng()
|
61 |
+
self.batch_default_infer_seed = rng.np_rng()
|
62 |
|
63 |
def segment_to_generate_params(self, segment: Dict[str, Any]) -> Dict[str, Any]:
|
64 |
if segment.get("params", None) is not None:
|
modules/utils/SeedContext.py
CHANGED
@@ -37,9 +37,9 @@ class SeedContext:
|
|
37 |
assert is_numeric(seed), "Seed must be an number."
|
38 |
|
39 |
try:
|
40 |
-
self.seed = int(np.clip(int(seed), -1, 2**32 - 1))
|
41 |
except Exception as e:
|
42 |
-
raise ValueError("Seed must be an integer
|
43 |
|
44 |
self.seed = seed
|
45 |
self.state = None
|
|
|
37 |
assert is_numeric(seed), "Seed must be an number."
|
38 |
|
39 |
try:
|
40 |
+
self.seed = int(np.clip(int(seed), -1, 2**32 - 1, out=None, dtype=np.int64))
|
41 |
except Exception as e:
|
42 |
+
raise ValueError(f"Seed must be an integer, but: {type(seed)}")
|
43 |
|
44 |
self.seed = seed
|
45 |
self.state = None
|
modules/utils/rng.py
CHANGED
@@ -1,15 +1,14 @@
|
|
1 |
import numpy as np
|
2 |
import torch
|
3 |
-
import random
|
4 |
|
5 |
-
TORCH_RNG_MAX =
|
6 |
-
TORCH_RNG_MIN =
|
7 |
|
8 |
NP_RNG_MAX = np.iinfo(np.uint32).max
|
9 |
NP_RNG_MIN = 0
|
10 |
|
11 |
|
12 |
-
def
|
13 |
torch.manual_seed(seed)
|
14 |
random_float = torch.empty(1).uniform_().item()
|
15 |
torch_rn = int(random_float * (TORCH_RNG_MAX - TORCH_RNG_MIN) + TORCH_RNG_MIN)
|
@@ -30,6 +29,7 @@ def np_rng():
|
|
30 |
if __name__ == "__main__":
|
31 |
import random
|
32 |
|
|
|
33 |
s1 = np_rng()
|
34 |
-
s2 =
|
35 |
print(f"s1 {s1} => s2: {s2}")
|
|
|
1 |
import numpy as np
|
2 |
import torch
|
|
|
3 |
|
4 |
+
TORCH_RNG_MAX = 0xFFFF_FFFF_FFFF_FFFF
|
5 |
+
TORCH_RNG_MIN = -0x8000_0000_0000_0000
|
6 |
|
7 |
NP_RNG_MAX = np.iinfo(np.uint32).max
|
8 |
NP_RNG_MIN = 0
|
9 |
|
10 |
|
11 |
+
def torch_rng(seed: int):
|
12 |
torch.manual_seed(seed)
|
13 |
random_float = torch.empty(1).uniform_().item()
|
14 |
torch_rn = int(random_float * (TORCH_RNG_MAX - TORCH_RNG_MIN) + TORCH_RNG_MIN)
|
|
|
29 |
if __name__ == "__main__":
|
30 |
import random
|
31 |
|
32 |
+
print(TORCH_RNG_MIN, TORCH_RNG_MAX)
|
33 |
s1 = np_rng()
|
34 |
+
s2 = torch_rng(s1)
|
35 |
print(f"s1 {s1} => s2: {s2}")
|
webui.py
CHANGED
@@ -148,7 +148,7 @@ def tts_generate(
|
|
148 |
prompt1 = prompt1 or params.get("prompt1", "")
|
149 |
prompt2 = prompt2 or params.get("prompt2", "")
|
150 |
|
151 |
-
infer_seed = np.clip(infer_seed, -1, 2**32 - 1)
|
152 |
infer_seed = int(infer_seed)
|
153 |
|
154 |
if not disable_normalize:
|
|
|
148 |
prompt1 = prompt1 or params.get("prompt1", "")
|
149 |
prompt2 = prompt2 or params.get("prompt2", "")
|
150 |
|
151 |
+
infer_seed = np.clip(infer_seed, -1, 2**32 - 1, out=None, dtype=np.int64)
|
152 |
infer_seed = int(infer_seed)
|
153 |
|
154 |
if not disable_normalize:
|