summaryrefslogtreecommitdiffstats
path: root/Scripts/transcribe_v2.py
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-09-09 21:41:36 -0700
committeryum <yum.food.vr@gmail.com>2023-09-09 21:46:10 -0700
commit286dcae5e087db817f3350cf442145107b25bc9c (patch)
tree48b3d9d332923f8cc11f8cf9d72d5d223f619a0b /Scripts/transcribe_v2.py
parent80714a0295df71d6dee35182d221648680f5f7d6 (diff)
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.
Diffstat (limited to 'Scripts/transcribe_v2.py')
-rw-r--r--Scripts/transcribe_v2.py9
1 files changed, 9 insertions, 0 deletions
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):