diff options
| author | yum <yum.food.vr@gmail.com> | 2022-12-20 22:21:44 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2022-12-20 22:30:11 -0800 |
| commit | 29070e5e68a0fef0cf8de2d5e4443bf04c00f340 (patch) | |
| tree | fe093f1b0fc3c3c12a46f2a9805c85d0c9f07d7b /Scripts/transcribe.py | |
| parent | ac69366dccaf377d20f029b4b58bac2314f61159 (diff) | |
Control tweak: introduce long/short hold behavior
The typical use pattern is now possible without entering radial.
Leaving mounted to the world for a long time is no longer possible.
Maybe I need an override param?
Left joystick controls:
* Short press toggle 1: show board, lock to hand, start transcribing
* Short press toggle 2: lock to world, stop transcribing
* Long press: hide board, stop transcribing
Diffstat (limited to 'Scripts/transcribe.py')
| -rw-r--r-- | Scripts/transcribe.py | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/Scripts/transcribe.py b/Scripts/transcribe.py index 831ae66..c72fb9f 100644 --- a/Scripts/transcribe.py +++ b/Scripts/transcribe.py @@ -297,28 +297,50 @@ def readControllerInput(audio_state): state = PAUSE_STATE osc_ctrl.indicateSpeech(audio_state.osc_client, False) osc_ctrl.indicatePaging(audio_state.osc_client, False) + + last_rising = time.time() while audio_state.run_app == True: time.sleep(0.05) event = steamvr.pollButtonPress(session) if event == steamvr.EVENT_RISING_EDGE: - print("event get") - if state == RECORD_STATE: + last_rising = time.time() + elif event == steamvr.EVENT_FALLING_EDGE: + now = time.time() + if now - last_rising > 0.5: + # Long hold state = PAUSE_STATE osc_ctrl.indicateSpeech(audio_state.osc_client, False) - playsound(os.path.abspath("../Sounds/Noise_Off.wav")) - - audio_state.audio_paused = True - elif state == PAUSE_STATE: - state = RECORD_STATE - osc_ctrl.indicateSpeech(audio_state.osc_client, True) - playsound(os.path.abspath("../Sounds/Noise_On.wav")) + osc_ctrl.toggleBoard(audio_state.osc_client, False) + #playsound(os.path.abspath("../Sounds/Noise_Off.wav")) resetAudioLocked(audio_state) resetDisplayLocked(audio_state) audio_state.drop_transcription = True - audio_state.audio_paused = False + audio_state.audio_paused = True + else: + # Short hold + if state == RECORD_STATE: + state = PAUSE_STATE + osc_ctrl.indicateSpeech(audio_state.osc_client, False) + osc_ctrl.lockWorld(audio_state.osc_client, True) + + audio_state.audio_paused = True + + playsound(os.path.abspath("../Sounds/Noise_Off.wav")) + elif state == PAUSE_STATE: + state = RECORD_STATE + osc_ctrl.indicateSpeech(audio_state.osc_client, True) + osc_ctrl.toggleBoard(audio_state.osc_client, True) + osc_ctrl.lockWorld(audio_state.osc_client, False) + resetAudioLocked(audio_state) + resetDisplayLocked(audio_state) + + audio_state.drop_transcription = True + audio_state.audio_paused = False + + playsound(os.path.abspath("../Sounds/Noise_On.wav")) # model should correspond to one of the Whisper models defined in # whisper/__init__.py. Examples: tiny, base, small, medium. @@ -365,7 +387,6 @@ def transcribeLoop(mic: str, language: str, model: str): transcribe_audio_thd.join() controller_input_thd.join() - if __name__ == "__main__": # Set cwd to the directory holding the script abspath = os.path.abspath(__file__) |
