From 286dcae5e087db817f3350cf442145107b25bc9c Mon Sep 17 00:00:00 2001 From: yum Date: Sat, 9 Sep 2023 21:41:36 -0700 Subject: Constrain log file, UI text field, and transcript sizes Log file is constrained to 1 MB and UI to 100-200 lines. 1k lines is too high to keep the UI from lagging. Transcript is constrained to 4k characters. Also put a 5 ms sleep in the transcription hot path. --- Scripts/transcribe_v2.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Scripts') diff --git a/Scripts/transcribe_v2.py b/Scripts/transcribe_v2.py index eae3830..81a4bf2 100644 --- a/Scripts/transcribe_v2.py +++ b/Scripts/transcribe_v2.py @@ -566,6 +566,8 @@ def evaluate(cfg, last_commit_ts = None while True: + time.sleep(.005) + commit = committer.getDelta() if last_commit_ts != None and collector.now() - last_commit_ts > 30: @@ -577,6 +579,8 @@ def evaluate(cfg, last_commit_ts = collector.now() transcript += commit.delta + # Hard-cap transcript length at 4k. + transcript = transcript[-4096:] preview = commit.preview if False and len(commit.delta): @@ -657,6 +661,8 @@ def optimize(cfg, def transcriptionThread(ctrl: ThreadControl): while ctrl.run_app: + time.sleep(.005) + op = None commit = ctrl.committer.getDelta() @@ -673,6 +679,9 @@ def transcriptionThread(ctrl: ThreadControl): print("Finalized: 1") ctrl.transcript += commit.delta + # Hard-cap transcript length at 4k characters to prevent runaway memory + # use. + ctrl.transcript = ctrl.transcript[-4096:] ctrl.preview = ctrl.transcript + commit.preview def vrInputThread(ctrl: ThreadControl): -- cgit v1.2.3