summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2022-12-20 22:21:44 -0800
committeryum <yum.food.vr@gmail.com>2022-12-20 22:30:11 -0800
commit29070e5e68a0fef0cf8de2d5e4443bf04c00f340 (patch)
treefe093f1b0fc3c3c12a46f2a9805c85d0c9f07d7b
parentac69366dccaf377d20f029b4b58bac2314f61159 (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
-rw-r--r--GUI/GUI/GUI/Frame.cpp1
-rw-r--r--Scripts/osc_ctrl.py8
-rw-r--r--Scripts/transcribe.py43
3 files changed, 41 insertions, 11 deletions
diff --git a/GUI/GUI/GUI/Frame.cpp b/GUI/GUI/GUI/Frame.cpp
index 5029c9c..5c1fbeb 100644
--- a/GUI/GUI/GUI/Frame.cpp
+++ b/GUI/GUI/GUI/Frame.cpp
@@ -487,6 +487,7 @@ void Frame::OnSetupPython(wxCommandEvent& event)
void Frame::OnDumpMics(wxCommandEvent& event)
{
transcribe_out_->AppendText(PythonWrapper::DumpMics());
+ transcribe_out_->AppendText("\n");
}
#define DEBUG
diff --git a/Scripts/osc_ctrl.py b/Scripts/osc_ctrl.py
index 34d1a36..a7dcc2b 100644
--- a/Scripts/osc_ctrl.py
+++ b/Scripts/osc_ctrl.py
@@ -329,6 +329,14 @@ def clear(client, tx_state):
tx_state.last_msg_encoded = []
+def lockWorld(client, lock: bool):
+ addr = "/avatar/parameters/" + generate_utils.getLockWorldParam()
+ client.send_message(addr, lock)
+
+def toggleBoard(client, show: bool):
+ addr = "/avatar/parameters/" + generate_utils.getToggleParam()
+ client.send_message(addr, show)
+
def indicateSpeech(client, is_speaking: bool):
addr = "/avatar/parameters/" + generate_utils.getIndicator0Param()
client.send_message(addr, is_speaking)
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__)