summaryrefslogtreecommitdiffstats
path: root/Scripts/osc_ctrl.py
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2023-01-22 15:05:54 -0800
committeryum <yum.food.vr@gmail.com>2023-01-22 15:35:00 -0800
commit1c056bf385d2c48f6e4f77da513060c04415252c (patch)
tree81091edb39e9e2b18652141dd3723751284c82ce /Scripts/osc_ctrl.py
parent06160c37acb26cfac9bab568bd3759c2386fb175 (diff)
Enable using built-in chatboxv0.3
VRChat exposes a built-in chatbox which can be seen by anyone who has it enabled. This was not the case when I started this project: the chatbox would only be visible to friends. Since this is clearly useful, enabling the STT on public models, let's enable sending data to it. Caveats: * The built-in chatbox has anti-spam tech which limits us to updating about once every 2 seconds. The custom chatbox has no such limitation and is thus typically much faster.
Diffstat (limited to 'Scripts/osc_ctrl.py')
-rw-r--r--Scripts/osc_ctrl.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Scripts/osc_ctrl.py b/Scripts/osc_ctrl.py
index 7c7d0ae..e57a843 100644
--- a/Scripts/osc_ctrl.py
+++ b/Scripts/osc_ctrl.py
@@ -30,6 +30,7 @@ class OscState:
self.client = getClient(ip, port)
self.pager = MultiLinePager(chars_per_sync, rows, cols)
self.encoding= generateEncoding()
+ self.builtin_msg = "" # The last message sent to the built-in chatbox
def reset(self):
self.pager.reset()
@@ -137,6 +138,23 @@ def pageMessage(osc_state: OscState, msg: str) -> bool:
addr="/avatar/parameters/" + generate_utils.getSpeechNoiseToggleParam()
osc_state.client.send_message(addr, False)
+# Like `pageMessage` but uses the built-in chatbox. The built-in chatbox
+# truncates data at about 150 chars, so just send the suffix of the message for
+# now.
+def pageMessageBuiltin(osc_state: OscState, msg: str) -> bool:
+ msg_begin = max(len(msg) - 140, 0)
+ msg_suffix = msg[msg_begin:len(msg)]
+
+ if osc_state.builtin_msg != msg:
+ addr="/chatbox/typing"
+ osc_state.client.send_message(addr, False)
+
+ addr="/chatbox/input"
+ osc_state.client.send_message(addr, (msg_suffix, True))
+ osc_state.builtin_msg = msg
+
+ return False # Not paging
+
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-i", default="127.0.0.1", help="OSC server IP")