summaryrefslogtreecommitdiffstats
path: root/osc_ctrl.py
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2022-11-12 14:14:49 -0800
committeryum <yum.food.vr@gmail.com>2022-11-12 14:14:49 -0800
commit3b038d23ec7621e0164c1901b416bf77a27d8cf3 (patch)
treee92badc27b9a93bd7173de993da02a20a560a778 /osc_ctrl.py
parent8a7858ad4e965f5410faa4ae5e7ad4f79a280d43 (diff)
Clicking the left joystick resets the board.
* Increase no speech probability threshold. This is what was preventing short transcriptions from working. We rely more on the avg logprob filter now. * Remove string matching logic from transcribe. Now when we get 2 consecutive identical transcriptions, we commit the transcription. This *could* cause words to get cut off but in practice it doesn't seem to happen. * Fix steamvr joystick click detection. Moving the joystick would also fire the event, which is not correct. * Combine locks in transcribe.py. * Remove "clear" vocal control. * osc_ctrl.clear() resets last_message_encoded * Remove osc_ctrl.sendMessage (unused)
Diffstat (limited to 'osc_ctrl.py')
-rw-r--r--osc_ctrl.py40
1 files changed, 13 insertions, 27 deletions
diff --git a/osc_ctrl.py b/osc_ctrl.py
index 5fadd6f..2e7ef39 100644
--- a/osc_ctrl.py
+++ b/osc_ctrl.py
@@ -243,6 +243,15 @@ def sendMessageLazy(client, msg, tx_state):
if cell_msg == last_cell_msg:
continue
+ # Skip cells on previous pages. This mitigates a bug where updating the
+ # earlier part of a transcription causes that text to overwrite text
+ # from a later part of the transcription.
+ page = floor(cell / (2 ** generate_utils.INDEX_BITS))
+ last_cell = (len(tx_state.last_msg_encoded) / NUM_LAYERS) - 1
+ last_page = floor(last_cell / (2 ** generate_utils.INDEX_BITS))
+ if page < last_page:
+ continue
+
if cell_msg == [state.encoding[' ']] * NUM_LAYERS:
if empty_cells_sent >= tx_state.empty_cells_to_send_per_call:
return False
@@ -261,31 +270,6 @@ def sendMessageLazy(client, msg, tx_state):
#resizeBoard(len(lines), tx_state, shrink_only=True)
return True
-def sendMessage(client, msg, page_sleep_s):
- lines = splitMessage(msg)
- msg = encodeMessage(lines)
- msg_len = len(msg)
-
- print("Encoded message: {}".format(msg))
-
- #openBoard()
-
- n_cells = ceil(msg_len / NUM_LAYERS)
- print("n_cells: {}".format(n_cells))
- for cell in range(0, n_cells):
- if cell > 0 and cell % (2 ** generate_utils.INDEX_BITS) == 0:
- print("Sleeping before sending next page")
- time.sleep(page_sleep_s)
-
- cell_begin = cell * NUM_LAYERS
- cell_end = (cell + 1) * NUM_LAYERS
- cell_msg = msg[cell_begin:cell_end]
- print("Send cell {}".format(cell))
- sendMessageCellDiscrete(client, cell_msg, cell)
-
- #closeBoard()
- #clear()
-
def sendRawMessage(client, msg):
n_cells = ceil(len(msg) / NUM_LAYERS)
for cell in range(0, n_cells):
@@ -295,7 +279,7 @@ def sendRawMessage(client, msg):
#print("Send cell {}".format(cell))
sendMessageCellDiscrete(client, cell_msg, cell)
-def clear(client):
+def clear(client, tx_state):
disable(client)
addr="/avatar/parameters/" + generate_utils.getClearBoardParam()
@@ -306,6 +290,8 @@ def clear(client):
addr="/avatar/parameters/" + generate_utils.getClearBoardParam()
client.send_message(addr, False)
+ tx_state.last_message_encoded = []
+
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-i", default="127.0.0.1", help="OSC server IP")
@@ -325,5 +311,5 @@ if __name__ == "__main__":
for line in fileinput.input():
while not sendMessageLazy(client, line, tx_state):
continue
- clear()
+ clear(client, tx_state)