g2p / fix.py
roedoejet1's picture
fix: change checkpoint from dp to deep_phonemizer
896a149
raw
history blame contribute delete
779 Bytes
# Script to rename checkpoint from dp to deep_phonemizer
import io, zipfile, torch
old = "model_step_420k.pt"
new = "model_step_420k_fixed.pt"
# Step 1. Read zip members
with open(old, "rb") as f:
data = f.read()
with zipfile.ZipFile(io.BytesIO(data)) as zin:
buf = io.BytesIO()
with zipfile.ZipFile(buf, "w", compression=zipfile.ZIP_DEFLATED) as zout:
for item in zin.infolist():
file_bytes = zin.read(item.filename)
file_bytes = file_bytes.replace(b"dp.", b"deep_phonemizer.")
zout.writestr(item, file_bytes)
# Step 2. Save the modified zip
with open(new, "wb") as f:
f.write(buf.getvalue())
# Step 3. Verify
checkpoint = torch.load(new, map_location="cpu", weights_only=False)
print("✅ Loaded successfully")