# Patch for RVC WebUI to handle PyTorch 2.5+ torch.load security
# This allows loading fairseq models which contain fairseq.data.dictionary.Dictionary

import torch.serialization

# Add fairseq Dictionary as a safe global for torch.load
try:
    from fairseq.data.dictionary import Dictionary
    torch.serialization.add_safe_globals([Dictionary])
    print("✓ Added fairseq.data.dictionary.Dictionary to torch safe globals")
except ImportError:
    print("⚠ fairseq not found, skipping safe globals registration")
