diff options
| author | yum <yum.food.vr@gmail.com> | 2023-05-22 15:35:17 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2023-05-22 15:50:12 -0700 |
| commit | 2d302f73b94a6aa3b2127443c1ba7ddfc9c82052 (patch) | |
| tree | 06862f018f9538890232f7f03c8227977d9789ec /Scripts/transcribe.py | |
| parent | 34d369b57780ed7ed5fb8d4f4b254e99c5fcb12d (diff) | |
Add ability to update textbox in place
By holding the button while talking for at least 1.5 seconds, you can
update the contents of the textbox without unlocking it from worldspace.
So now you can carefully position your textbox once, then continually
speak into it without having to reposition it every time.
Diffstat (limited to 'Scripts/transcribe.py')
| -rw-r--r-- | Scripts/transcribe.py | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/Scripts/transcribe.py b/Scripts/transcribe.py index 366f3a2..422e9c0 100644 --- a/Scripts/transcribe.py +++ b/Scripts/transcribe.py @@ -380,9 +380,25 @@ def readControllerInput(audio_state, enable_local_beep: bool, if event == steamvr.EVENT_RISING_EDGE: last_rising = time.time() + + if state == PAUSE_STATE: + resetAudioLocked(audio_state) + resetDisplayLocked(audio_state) + audio_state.drop_transcription = True + audio_state.audio_paused = False + elif event == steamvr.EVENT_FALLING_EDGE: now = time.time() - if now - last_rising > 0.5: + if now - last_rising > 1.5: + # Very long hold: treat as the end of transcription. + state = PAUSE_STATE + if not use_builtin: + osc_ctrl.indicateSpeech(audio_state.osc_state.client, False) + osc_ctrl.lockWorld(audio_state.osc_state.client, True) + audio_state.transcribe_sleep_duration = audio_state.transcribe_sleep_duration_min_s + audio_state.audio_paused = True + + elif now - last_rising > 0.5: # Long hold state = PAUSE_STATE if not use_builtin: @@ -413,11 +429,6 @@ def readControllerInput(audio_state, enable_local_beep: bool, osc_ctrl.indicateSpeech(audio_state.osc_state.client, True) osc_ctrl.toggleBoard(audio_state.osc_state.client, True) osc_ctrl.lockWorld(audio_state.osc_state.client, False) - resetAudioLocked(audio_state) - resetDisplayLocked(audio_state) - - audio_state.drop_transcription = True - audio_state.audio_paused = False if enable_local_beep == 1: playsound(os.path.abspath("Resources/Sounds/Noise_On_Quiet.wav")) @@ -449,10 +460,10 @@ def transcribeLoop(mic: str, language: str, model: str, if download_it: model = model_root model = WhisperModel(model, - device=model_device, - compute_type="int8", - download_root=model_root, - local_files_only=download_it) + device = model_device, + compute_type = "int8", + download_root = model_root, + local_files_only = download_it) transcribe_audio_thd = threading.Thread(target = transcribeAudio, args = [audio_state, model, use_cpu]) transcribe_audio_thd.daemon = True |
