Spaces:
Sleeping
Sleeping
| 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])) | |