Skip to content

Commit

Permalink
v2 rewrite (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl authored Jun 28, 2023
1 parent c4e2dfc commit 206f311
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 1,895 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

10 changes: 0 additions & 10 deletions enroll.py

This file was deleted.

1 change: 1 addition & 0 deletions hivemind_voice_satellite/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from hivemind_voice_satellite.service import VoiceClient
47 changes: 47 additions & 0 deletions hivemind_voice_satellite/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import click
from hivemind_bus_client import HiveMessageBusClient
from ovos_audio.service import PlaybackService
from ovos_utils import wait_for_exit_signal

from hivemind_voice_satellite import VoiceClient


@click.command(help="connect to HiveMind")
@click.option("--host", help="hivemind host", type=str, default="wss://127.0.0.1")
@click.option("--key", help="Access Key", type=str)
@click.option("--password", help="Password for key derivation", type=str)
@click.option("--port", help="HiveMind port number", type=int, default=5678)
@click.option("--selfsigned", help="accept self signed certificates", is_flag=True)
def connect(host, key, password, port, selfsigned):
if not host.startswith("ws"):
print("Invalid host, please specify a protocol")
print(f"ws://{host} or wss://{host}")
exit(1)

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

# create Audio Output interface (TTS/Music)
audio = PlaybackService(bus=bus, disable_ocp=True, validate_source=False)
audio.daemon = True
audio.start()

# STT listener thread
service = VoiceClient(bus=bus)
service.daemon = True
service.start()

wait_for_exit_signal()

service.stop()
audio.shutdown()


if __name__ == '__main__':
connect()
36 changes: 36 additions & 0 deletions hivemind_voice_satellite/service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from hivemind_bus_client.client import HiveMessageBusClient
from ovos_dinkum_listener.service import OVOSDinkumVoiceService
from ovos_utils.log import LOG


def on_ready():
LOG.info('HiveMind Voice Satellite is ready.')


def on_started():
LOG.info('HiveMind Voice Satellite started.')


def on_alive():
LOG.info('HiveMind Voice Satellite alive.')


def on_stopping():
LOG.info('HiveMind Voice Satellite is shutting down...')


def on_error(e='Unknown'):
LOG.error(f'HiveMind Voice Satellite failed to launch ({e}).')


class VoiceClient(OVOSDinkumVoiceService):
"""HiveMind Voice Satellite, but bus is replaced with hivemind connection"""

def __init__(self, bus: HiveMessageBusClient, on_ready=on_ready, on_error=on_error,
on_stopping=on_stopping, on_alive=on_alive,
on_started=on_started, watchdog=lambda: None, mic=None):
super().__init__(on_ready, on_error, on_stopping, on_alive, on_started, watchdog, mic)
self.bus = bus

def _connect_to_bus(self):
pass
185 changes: 0 additions & 185 deletions mycroft_voice_satellite/__init__.py

This file was deleted.

56 changes: 0 additions & 56 deletions mycroft_voice_satellite/__main__.py

This file was deleted.

Loading

0 comments on commit 206f311

Please sign in to comment.