Created
April 30, 2023 22:13
-
-
Save uyjulian/ee2082ca812478bddac5bc112e9b6c88 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sen4 voice table decode | |
import struct | |
import functools | |
import itertools | |
import sys | |
import os | |
import io | |
def read_null_ending_string(f): | |
toeof = iter(functools.partial(f.read, 1), b'') | |
return sys.intern((b''.join(itertools.takewhile(b'\0'.__ne__, toeof))).decode("ASCII")) | |
with open("t_voice.tbl", "rb") as f: | |
f.seek(16) | |
total_size = os.fstat(f.fileno()).st_size | |
while f.tell() != total_size: | |
f.seek(6, io.SEEK_CUR) | |
llen = struct.unpack("<H", f.read(2))[0] | |
nnext = f.tell() + llen | |
iid = struct.unpack("<H", f.read(2))[0] | |
f.seek(1, io.SEEK_CUR) | |
filename = read_null_ending_string(f) | |
print(str(iid) + "\t" + filename) | |
f.seek(nnext) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment