Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance/real_websocket #41

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions hivemind_voice_satellite/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,31 @@
from hivemind_bus_client.identity import NodeIdentity
from hivemind_ggwave import GGWaveSlave
from ovos_audio.service import PlaybackService
from ovos_bus_client.client import MessageBusClient
from ovos_utils import wait_for_exit_signal
from ovos_utils.log import init_service_logger, LOG

from ovos_utils.fakebus import FakeBus
from hivemind_voice_satellite import VoiceClient


def launch_bus_daemon() -> MessageBusClient:
from ovos_utils import create_daemon
from tornado import web, ioloop
from ovos_messagebus.event_handler import MessageBusEventHandler

INTERNAL_PORT = 9987 # can be anything, wanted to differentiate from standard ovos-bus

routes = [("/core", MessageBusEventHandler)]
application = web.Application(routes)
application.listen(INTERNAL_PORT, "127.0.0.1")
create_daemon(ioloop.IOLoop.instance().start)

bus = MessageBusClient(host="127.0.0.1", port=INTERNAL_PORT)
bus.run_in_thread()
return bus


# TODO - add a flag to use FakeBus instead of real websocket
@click.command(help="connect to HiveMind")
@click.option("--host", help="hivemind host", type=str, default="")
@click.option("--key", help="Access Key", type=str, default="")
Expand Down Expand Up @@ -67,13 +86,17 @@ def handle_complete(message):
LOG.error(f"ws://{host} or wss://{host}")
exit(1)

# TODO - flag for fakebus
internal_bus = launch_bus_daemon() or FakeBus()

# connect to hivemind
bus = HiveMessageBusClient(key=key,
password=password,
port=port,
host=host,
useragent="VoiceSatelliteV0.3.0",
self_signed=selfsigned)
useragent="VoiceSatelliteV0.3.1",
self_signed=selfsigned,
internal_bus=internal_bus)
bus.connect(site_id=siteid)

# create Audio Output interface (TTS/Music)
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ ovos-stt-plugin-server
ovos-tts-plugin-server
ovos-ww-plugin-vosk
click
hivemind-ggwave
hivemind-ggwave
ovos-messagebus
Loading