Spaces:
Sleeping
Sleeping
File size: 633 Bytes
4393971 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | import os, tempfile, uuid
import batchalign as ba
def to_cha_from_wav(wav_path: str, lang: str = "eng") -> str:
"""Run Batchalign → CHAT and return path to .cha"""
nlp = ba.BatchalignPipeline.new("asr,morphosyntax", lang=lang)
doc = ba.Document.new(media_path=wav_path, lang=lang)
doc = nlp(doc)
chat = ba.CHATFile(doc=doc)
out_dir = tempfile.mkdtemp(prefix="cha_")
out_path = os.path.join(out_dir, f"{uuid.uuid4().hex}.cha")
chat.write(out_path, write_wor=True) # keep your preferred flags
return out_path
if __name__ == "__main__":
import sys
print(to_cha_from_wav(sys.argv[1]))
|