From 1c056bf385d2c48f6e4f77da513060c04415252c Mon Sep 17 00:00:00 2001 From: yum Date: Sun, 22 Jan 2023 15:05:54 -0800 Subject: Enable using built-in chatbox 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. --- Scripts/osc_ctrl.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Scripts/osc_ctrl.py') 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") -- cgit v1.2.3