Skip to content

Instantly share code, notes, and snippets.

@uyjulian
Created April 30, 2023 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uyjulian/ee2082ca812478bddac5bc112e9b6c88 to your computer and use it in GitHub Desktop.
Save uyjulian/ee2082ca812478bddac5bc112e9b6c88 to your computer and use it in GitHub Desktop.
# 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