ITS-C4SF733\Administrator
all resource
324bf29
raw
history blame contribute delete
575 Bytes
import random
import numpy as np
import torch
import uuid
def fix_random_seed(random_seed: int):
"""
Set the same random seed for the libraries and modules that Lhotse interacts with.
Includes the ``random`` module, numpy, torch, and ``uuid4()`` function defined in this file.
"""
global _lhotse_uuid
random.seed(random_seed)
np.random.seed(random_seed)
torch.random.manual_seed(random_seed)
# Ensure deterministic ID creation
rd = random.Random()
rd.seed(random_seed)
_lhotse_uuid = lambda: uuid.UUID(int=rd.getrandbits(128))