From adaa41f11465667f1631d9ad8110fbd78ab9d1b4 Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Fri, 15 Sep 2023 17:39:40 +0100 Subject: [PATCH 1/2] feat/ggwave --- hivemind_voice_satellite/__main__.py | 32 ++++++++++++++++++++++++++-- requirements.txt | 3 ++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/hivemind_voice_satellite/__main__.py b/hivemind_voice_satellite/__main__.py index 2dfb075..5987d63 100644 --- a/hivemind_voice_satellite/__main__.py +++ b/hivemind_voice_satellite/__main__.py @@ -4,7 +4,9 @@ from ovos_utils import wait_for_exit_signal from ovos_utils.log import init_service_logger, LOG from hivemind_voice_satellite import VoiceClient +from threading import Event from hivemind_bus_client.identity import NodeIdentity +from hivemind_ggwave import GGWaveSlave @click.command(help="connect to HiveMind") @@ -24,13 +26,39 @@ def connect(host, key, password, port, selfsigned, siteid): siteid = siteid or identity.site_id or "unknown" host = host or identity.default_master - if not host.startswith("ws://") and not host.startswith("wss://"): - host = "ws://" + host + if not password: + LOG.info("starting hivemind-ggwave, waiting for audio password") + try: + + ggwave = GGWaveSlave(key=key) # reuse existing key + + ready = Event() + + def handle_complete(message): + nonlocal identity, password, key, host, ready + identity.reload() + password = identity.password + host = identity.default_master + LOG.info(f"will connect to: {host}") + ready.set() + + + ggwave.bus.on("hm.ggwave.identity_updated", + handle_complete) + ggwave.start() + + ready.wait() + + except Exception as e: + LOG.exception("hivemind-ggwave failed to start") if not key or not password or not host: raise RuntimeError("NodeIdentity not set, please pass key/password/host or " "call 'hivemind-client set-identity'") + if not host.startswith("ws://") and not host.startswith("wss://"): + host = "ws://" + host + if not host.startswith("ws"): LOG.error("Invalid host, please specify a protocol") LOG.error(f"ws://{host} or wss://{host}") diff --git a/requirements.txt b/requirements.txt index 09b6554..f332c35 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ ovos-dinkum-listener>=0.0.2, < 0.1.0 ovos-vad-plugin-webrtcvad ovos-stt-plugin-server ovos-tts-plugin-server -click \ No newline at end of file +click +hivemind-ggwave \ No newline at end of file From 3eda6b99ee5cd4525411fb198ab3332e245e4927 Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Fri, 15 Sep 2023 18:34:42 +0100 Subject: [PATCH 2/2] feat/ggwave --- hivemind_voice_satellite/__main__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hivemind_voice_satellite/__main__.py b/hivemind_voice_satellite/__main__.py index 5987d63..72701d6 100644 --- a/hivemind_voice_satellite/__main__.py +++ b/hivemind_voice_satellite/__main__.py @@ -39,6 +39,7 @@ def handle_complete(message): identity.reload() password = identity.password host = identity.default_master + key = identity.access_key LOG.info(f"will connect to: {host}") ready.set() @@ -49,6 +50,8 @@ def handle_complete(message): ready.wait() + ggwave.stop() + except Exception as e: LOG.exception("hivemind-ggwave failed to start")