File size: 779 Bytes
896a149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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")