Skip to content

Commit

Permalink
Merge pull request #14 from JarbasHiveMind/release-0.7.0a2
Browse files Browse the repository at this point in the history
Release 0.7.0a2
  • Loading branch information
JarbasAl authored Dec 23, 2024
2 parents 246525b + b512e9f commit 3be8e4b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 17 deletions.
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
# Changelog

## [0.6.0a1](https://github.com/JarbasHiveMind/hivemind-mic-satellite/tree/0.6.0a1) (2024-10-30)
## [0.7.0a2](https://github.com/JarbasHiveMind/hivemind-mic-satellite/tree/0.7.0a2) (2024-12-23)

[Full Changelog](https://github.com/JarbasHiveMind/hivemind-mic-satellite/compare/0.5.0...0.6.0a1)
[Full Changelog](https://github.com/JarbasHiveMind/hivemind-mic-satellite/compare/0.7.0a1...0.7.0a2)

**Merged pull requests:**

- feat:media [\#9](https://github.com/JarbasHiveMind/hivemind-mic-satellite/pull/9) ([JarbasAl](https://github.com/JarbasAl))
- performance: speed up b64 operations [\#13](https://github.com/JarbasHiveMind/hivemind-mic-satellite/pull/13) ([JarbasAl](https://github.com/JarbasAl))

## [0.7.0a1](https://github.com/JarbasHiveMind/hivemind-mic-satellite/tree/0.7.0a1) (2024-12-21)

[Full Changelog](https://github.com/JarbasHiveMind/hivemind-mic-satellite/compare/0.6.0...0.7.0a1)

**Merged pull requests:**

- feat: cli interface [\#11](https://github.com/JarbasHiveMind/hivemind-mic-satellite/pull/11) ([JarbasAl](https://github.com/JarbasAl))



Expand Down
46 changes: 35 additions & 11 deletions hivemind_mic_sat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import base64
import pybase64
import os.path
from queue import Queue
from typing import Optional, List

from ovos_bus_client.message import Message

from hivemind_bus_client.client import HiveMessageBusClient, BinaryDataCallbacks
from hivemind_bus_client.message import HiveMessage, HiveMessageType
from hivemind_bus_client.serialization import HiveMindBinaryPayloadType
import click
from ovos_audio.audio import AudioService
from ovos_audio.playback import PlaybackThread as _PT
from ovos_bus_client.message import Message
from ovos_plugin_manager.microphone import OVOSMicrophoneFactory, Microphone
from ovos_plugin_manager.utils.tts_cache import hash_sentence
from ovos_plugin_manager.vad import OVOSVADFactory, VADEngine
from ovos_utils.fakebus import FakeBus
from ovos_utils.log import LOG
from ovos_utils.sound import play_audio

from hivemind_bus_client.client import HiveMessageBusClient, BinaryDataCallbacks
from hivemind_bus_client.identity import NodeIdentity
from hivemind_bus_client.message import HiveMessage, HiveMessageType
from hivemind_bus_client.serialization import HiveMindBinaryPayloadType


class PlaybackThread(_PT):
# TODO - send PR to ovos-audio adding util method
Expand Down Expand Up @@ -54,13 +56,13 @@ def handle_receive_tts(self, bin_data: bytes,

class HiveMindMicrophoneClient:

def __init__(self, prefer_b64=False, enable_media=True):
def __init__(self, prefer_b64=False, enable_media=True, **kwargs):
self.prefer_b64 = prefer_b64
internal = FakeBus()
self.playback: PlaybackThread = PlaybackThread(bus=internal,
queue=Queue())
self.hm_bus = HiveMessageBusClient(bin_callbacks=TTSHandler(self.playback),
internal_bus=internal)
internal_bus=internal, **kwargs)
self.hm_bus.connect(FakeBus())
self.hm_bus.connected_event.wait()
LOG.info("== connected to HiveMind")
Expand Down Expand Up @@ -135,7 +137,7 @@ def handle_speak_b64(self, message: Message):
utt = message.data["utterance"]
audio_file = f"/tmp/{hash_sentence(utt)}.wav"
with open(audio_file, "wb") as f:
f.write(base64.b64decode(b64data))
f.write(pybase64.b64decode(b64data))
LOG.info(f"TTS: {audio_file}")
self.playback.put(audio_file,
listen=message.data.get("listen"),
Expand Down Expand Up @@ -190,8 +192,30 @@ def stop(self):
self.mic.stop()


def run():
h = HiveMindMicrophoneClient()
@click.command()
@click.option("--key", help="HiveMind access key (default read from identity file)", type=str, default="")
@click.option("--password", help="HiveMind password (default read from identity file)", type=str, default="")
@click.option("--host", help="HiveMind host (default read from identity file)", type=str, default="")
@click.option("--port", help="HiveMind port number (default read from identity file or 5678)", type=int, required=False)
@click.option("--siteid", help="location identifier for message.context (default read from identity file)", type=str,
default="")
def run(key: str, password: str, host: str, port: int, siteid: str):
identity = NodeIdentity()
password = password or identity.password
key = key or identity.access_key
host = host or identity.default_master
identity.siteid = siteid or identity.site_id or "unknown"
port = port or identity.default_port or 5678

if not host.startswith("ws://") and not host.startswith("wss://"):
host = "ws://" + host

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'")

h = HiveMindMicrophoneClient(key=key, host=host, port=port,
password=password, identity=identity)
h.run()


Expand Down
4 changes: 2 additions & 2 deletions hivemind_mic_sat/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 0
VERSION_MINOR = 6
VERSION_MINOR = 7
VERSION_BUILD = 0
VERSION_ALPHA = 0
VERSION_ALPHA = 2
# END_VERSION_BLOCK
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
hivemind_bus_client>=0.1.0,<1.0.0
ovos-plugin-manager<1.0.0
ovos-audio<1.0.0
ovos-audio<1.0.0
click
pybase64

0 comments on commit 3be8e4b

Please sign in to comment.