From 4f3131b4a36d8e1557edb31d3754a431717dab7b Mon Sep 17 00:00:00 2001 From: yum Date: Fri, 30 Jun 2023 19:44:27 -0700 Subject: Add visual commit indicator to OBS browser source Circle goes red when speaking, grey when done. Ideally it would be in the top right portion of the browser source, but this is a good start. Also, hard-cap transcripts to 4096 chars. This prevents the STT from lagging during long sessions. --- Scripts/transcribe.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'Scripts') diff --git a/Scripts/transcribe.py b/Scripts/transcribe.py index c249e43..039811c 100644 --- a/Scripts/transcribe.py +++ b/Scripts/transcribe.py @@ -364,6 +364,18 @@ def transcribeAudio(audio_state, audio_state.text += text audio_state.preview_text = audio_state.text + preview_text + if len(preview_text) == 0: + print("Finalized: 1") + else: + print("Finalized: 0") + + # Hard cap transcript at 4096 chars. Letting it grow longer than this + # eventually causes lag. This happens routinely when streaming. Capping + # like this does not affect the visible portion of the transcript in + # OBS, but it might affect the visible portion in-game. (Don't make + # your friends read more than 4k characters on a fucking chatbox.) + audio_state.text = audio_state.text[-4096:] + now = time.time() if audio_state.enable_debug_mode: print("Raw transcription ({} seconds): {}".format( @@ -739,8 +751,6 @@ def transcribeLoop(mic: str, print(f"Translation ready to go") - print("Safe to start talking") - abspath = os.path.abspath(__file__) dname = os.path.dirname(abspath) model_root = os.path.join(dname, "Models", model) -- cgit v1.2.3