Skip to content

Commit

Permalink
Merge pull request #2 from JarbasHiveMind/release-1.0.0a1
Browse files Browse the repository at this point in the history
Release 1.0.0a1
  • Loading branch information
JarbasAl authored Oct 26, 2024
2 parents 6c841c6 + 536369f commit 695ea9d
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 272 deletions.
175 changes: 18 additions & 157 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,160 +1,21 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
dev.env
.dev_opts.json
.idea
*.code-workspace
*.pyc
*.swp
*~
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
build
dist
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
/htmlcov
.installed
.mypy_cache
.vscode
.theia
.venv/

# Created by unit tests
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
/.gtm/
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

## [1.0.0a1](https://github.com/JarbasHiveMind/HiveMind-voice-relay/tree/1.0.0a1) (2024-10-26)

[Full Changelog](https://github.com/JarbasHiveMind/HiveMind-voice-relay/compare/0.1.0...1.0.0a1)

**Breaking changes:**

- feat!:move to simple listener [\#1](https://github.com/JarbasHiveMind/HiveMind-voice-relay/pull/1) ([JarbasAl](https://github.com/JarbasAl))



\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
98 changes: 59 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,71 @@
### HiveMind Server Setups
# HiveMind Voice Relay

When building your HiveMind servers there are many ways to go about it, with many optional components
OpenVoiceOS Relay, connect to [HiveMind](https://github.com/JarbasHiveMind/HiveMind-listener)

Common setups:
A lightweight version of [voice-satellite](https://github.com/JarbasHiveMind/HiveMind-voice-sat), but STT and TTS are sent to HiveMind instead of handled on device

- **OVOS Device**, a full OVOS install without hivemind
- **Hivemind Device**, a OVOS device also running hivemind, eg. a Mark2 with it's own satellites.
- **Hivemind Skills Server**, a minimal HiveMind server that satellites can connect to, supports **text** utterances
only
- **Hivemind Sound Server**, a HiveMind server that supports **text** utterances and **streaming audio**
- **Hivemind Persona Server**, exposes a `ovos-persona` (eg. an LLM) that satellites can connect to, without
running `ovos-core`.
## Server requirements

The table below illustrates the most common setups for a OVOS based Mind, each column represents a running OVOS/HiveMind
service on your server
> ⚠️ `hivemind-listener` is required server side, the default `hivemind-core` does not provide STT and TTS capabilities.
| | **hivemind-core** | **hivemind-listener** | **ovos-core** | **ovos-audio** | **ovos-listener** | **hivemind-persona** |
|-----------------------------|-------------------|-----------------------|---------------|----------------|-------------------|----------------------|
| **OVOS Device** ||| ✔️ | ✔️ | ✔️ ||
| **Hivemind Device** | ✔️ || ✔️ | ✔️ | ✔️ ||
| **Hivemind Skills Server** | ✔️ || ✔️ ||||
| **Hivemind Sound Server** || ✔️ | ✔️ ||||
| **Hivemind Persona Server** |||||| ✔️ |
> Alternatively run `hivemind-core` together with `ovos-audio` and `ovos-dinkum-listener`
The table below indicates compatibility for each of the setups described above with the most common voice satellites,
each column corresponds to a different satellite
The regular voice satellite is built on top of [ovos-dinkum-listener](https://github.com/OpenVoiceOS/ovos-dinkum-listener) and is full featured supporting all plugins

| | **voice satellite** | **voice relay** | **mic satellite** |
|-----------------------------|---------------------|-----------------|-------------------|
| **OVOS Device** ||||
| **Hivemind Device** | ✔️ | ✔️ ||
| **Hivemind Skills Server** | ✔️ |||
| **Hivemind Sound Server** | ✔️ | ✔️ | ✔️ |
| **Hivemind Persona Server** | ✔️ |||
This repo is built on top of [ovos-simple-listener](https://github.com/TigreGotico/ovos-simple-listener), while it needs less resources it is also **missing** some features

### HiveMind Satellites
- STT plugin
- TTS plugin
- Audio Transformers plugins
- Continuous Listening
- Hybrid Listening
- Recording Mode
- Sleep Mode
- Multiple WakeWords

The table below illustrates how plugins from the OVOS ecosystem relate to the various satellites
If you need an even lighter implementation, consider [hivemind-mic-satellite](https://github.com/JarbasHiveMind/hivemind-mic-satellite) to also offload wake word to the server

**Emoji Key**
## Install

- ✔️: Local (on device)
- 📡: Remote (hivemind-listener)
- ❌: Unsupported
Install with pip

| Supported Plugins | **Microphone** | **VAD** | **Wake Word** | **STT** | **TTS** | **Media Playback** | **Transformers** | **PHAL** |
|-----------------------------------|------------------|------------------|------------------|------------------|------------------|--------------------|--------------------|--------------------|
| **HiveMind Voice Satellite** | ✔️<br>(Required) | ✔️<br>(Required) | ✔️<br>(Required) | ✔️<br>(Required) | ✔️<br>(Required) | ✔️<br>(Optional) | ✔️<br>(Optional) | ✔️<br>(Optional) |
| **HiveMind Voice Relay** | ✔️<br>(Required) | ✔️<br>(Required) | ✔️<br>(Required) | 📡<br>(Remote) | 📡<br>(Remote) | ✔️<br>(Optional) | ✔️<br>(Optional) | ✔️<br>(Optional) |
| **HiveMind Microphone Satellite** | ✔️<br>(Required) | ✔️<br>(Required) | 📡<br>(Remote) | 📡<br>(Remote) | 📡<br>(Remote) | ❌<br>(Unsupported) | ❌<br>(Unsupported) | ❌<br>(Unsupported) |
```bash
$ pip install HiveMind-voice-relay
```

## Usage

```bash
Usage: hivemind-voice-relay [OPTIONS]

connect to HiveMind

Options:
--host TEXT hivemind host
--key TEXT Access Key
--password TEXT Password for key derivation
--port INTEGER HiveMind port number
--selfsigned accept self signed certificates
--help Show this message and exit.

```

## Configuration

Voice relay is built on top of [ovos-simple-listener](https://github.com/TigreGotico/ovos-simple-listener) and [ovos-audio](https://github.com/OpenVoiceOS/ovos-audio), it uses the default OpenVoiceOS configuration `~/.config/mycroft/mycroft.conf`

Supported plugin types:

| Plugin Type | Description | Required | Link |
|-------------|-------------|----------|------|
| Microphone | Captures voice input | Yes | [Microphone](https://openvoiceos.github.io/ovos-technical-manual/mic_plugins/) |
| VAD | Voice Activity Detection | Yes | [VAD](https://openvoiceos.github.io/ovos-technical-manual/vad_plugins/) |
| WakeWord | Detects wake words for interaction | Yes* | [WakeWord](https://openvoiceos.github.io/ovos-technical-manual/ww_plugins/) |
| STT | speech-to-text (STT)| Yes | [STT](https://openvoiceos.github.io/ovos-technical-manual/stt_plugins/) |
| TTS | text-to-speech (TTS) | Yes | [TTS](https://openvoiceos.github.io/ovos-technical-manual/tts_plugins) |
| G2P | grapheme-to-phoneme (G2P), used to simulate mouth movements | No | [G2P](https://openvoiceos.github.io/ovos-technical-manual/g2p_plugins) |
| Media Playback Plugins | Enables media playback (e.g., "play Metallica") | No | [Media Playback Plugins](https://openvoiceos.github.io/ovos-technical-manual/media_plugins/) |
| OCP Plugins | Provides playback support for URLs (e.g., YouTube) | No | [OCP Plugins](https://openvoiceos.github.io/ovos-technical-manual/ocp_plugins/) |
| Dialog Transformers | Processes text before text-to-speech (TTS) | No | [Dialog Transformers](https://openvoiceos.github.io/ovos-technical-manual/transformer_plugins/) |
| TTS Transformers | Processes audio after text-to-speech (TTS) | No | [TTS Transformers](https://openvoiceos.github.io/ovos-technical-manual/transformer_plugins/) |
| PHAL | Provides platform-specific support (e.g., Mark 1) | No | [PHAL](https://openvoiceos.github.io/ovos-technical-manual/PHAL/) |
1 change: 0 additions & 1 deletion hivemind_voice_relay/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from hivemind_voice_relay.service import VoiceRelay, AudioPlaybackRelay
49 changes: 9 additions & 40 deletions hivemind_voice_relay/__main__.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,22 @@
from threading import Event

import click
from hivemind_bus_client import HiveMessageBusClient
from hivemind_bus_client.identity import NodeIdentity
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_relay.service import VoiceRelay, AudioPlaybackRelay


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
from ovos_utils.log import init_service_logger, LOG

from hivemind_bus_client import HiveMessageBusClient
from hivemind_bus_client.identity import NodeIdentity
from hivemind_voice_relay.service import HiveMindVoiceRelay


# TODO - add a flag to use FakeBus instead of real websocket
@click.command(help="connect to HiveMind")
@click.command(help="connect to HiveMind Sound Server")
@click.option("--host", help="hivemind host", type=str, default="")
@click.option("--key", help="Access Key", type=str, default="")
@click.option("--password", help="Password for key derivation", type=str, default="")
@click.option("--port", help="HiveMind port number", type=int, default=5678)
@click.option("--selfsigned", help="accept self signed certificates", is_flag=True)
@click.option("--siteid", help="location identifier for message.context", type=str, default="")
@click.option("--fakebus", help="use FakeBus instead of real websocket", is_flag=True)
def connect(host, key, password, port, selfsigned, siteid, fakebus):
def connect(host, key, password, port, selfsigned, siteid):
init_service_logger("HiveMind-voice-relay")

identity = NodeIdentity()
Expand All @@ -58,29 +37,20 @@ def connect(host, key, password, port, selfsigned, siteid, fakebus):
LOG.error(f"ws://{host} or wss://{host}")
exit(1)

# Check for fakebus flag
if fakebus:
internal_bus = FakeBus()
else:
internal_bus = launch_bus_daemon() or FakeBus()
internal_bus = FakeBus()

# connect to hivemind
bus = HiveMessageBusClient(key=key,
password=password,
port=port,
host=host,
useragent="VoiceRelayV0.0.1",
useragent="VoiceRelayV1.0.0",
self_signed=selfsigned,
internal_bus=internal_bus)
bus.connect(site_id=siteid)

# create Audio Output interface (TTS/Music)
audio = AudioPlaybackRelay(bus=bus)
audio.daemon = True
audio.start()

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

Expand All @@ -95,7 +65,6 @@ def connect(host, key, password, port, selfsigned, siteid, fakebus):
wait_for_exit_signal()

service.stop()
audio.shutdown()
if phal:
phal.shutdown()

Expand Down
Loading

0 comments on commit 695ea9d

Please sign in to comment.