Last active
December 12, 2025 01:15
-
-
Save hathibelagal-dev/84cb46af07cdf70a95c0bfe9c4f88c6d to your computer and use it in GitHub Desktop.
Parses timedtext files
This file contains hidden or 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
| import json | |
| import sys | |
| if len(sys.argv) != 2: | |
| print("ERROR: Provide input file") | |
| try: | |
| with open(sys.argv[1]) as f: | |
| data = f.read() | |
| except: | |
| print("ERROR: Couldn't read file") | |
| try: | |
| data = json.loads(data) | |
| data = data["events"] | |
| for item in data: | |
| if "segs" in item: | |
| segs = item["segs"] | |
| for seg in segs: | |
| if "utf8" in seg: | |
| print(seg["utf8"], end="") | |
| except Exception as e: | |
| print(e) | |
| print("ERROR: Couldn't process file") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment