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

Add optional dependencies and make backend optional #67

Merged
merged 5 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,19 @@ the usual configuration files are loaded, some new params are exposed under the

## Install

using [ovos-vad-plugin-silero](https://github.com/OpenVoiceOS/ovos-vad-plugin-silero)
`pip install ovos-dinkum-listener[extras]` to install this package and the default
plugins. Note that by default, either `tensorflow` or `tflite_runtime` will need
to be installed separately for wakeword detection.

> If unable to install tflite_runtime in your platform, you can find wheels
> here https://whl.smartgic.io/. eg, for pyhon 3.11 in x86
> `pip install https://whl.smartgic.io/tflite_runtime-2.13.0-cp311-cp311-linux_x86_64.whl`

Without `extras`, wakeword and STT audio upload will be disabled unless you install
[`ovos-backend-client`](https://github.com/OpenVoiceOS/ovos-backend-client) separately. You will also need to manually install,
and possibly configure STT, WW, and VAD modules as described below.

Using [ovos-vad-plugin-silero](https://github.com/OpenVoiceOS/ovos-vad-plugin-silero)
is strongly recommended instead of the default webrtcvad plugin

## Configuration
Expand Down
26 changes: 17 additions & 9 deletions ovos_dinkum_listener/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from pathlib import Path
from threading import Thread, RLock, Event

from ovos_backend_client.api import DatasetApi
from ovos_bus_client import Message, MessageBusClient
from ovos_bus_client.session import SessionManager
from ovos_config import Configuration
Expand All @@ -37,6 +36,12 @@
from ovos_dinkum_listener.voice_loop import DinkumVoiceLoop, ListeningMode, ListeningState
from ovos_dinkum_listener.voice_loop.hotwords import HotwordContainer

try:
from ovos_backend_client.api import DatasetApi
except ImportError:
LOG.info("`ovos-backend-client` is not installed. Upload is disabled")
DatasetApi = None

# Seconds between systemd watchdog updates
WATCHDOG_DELAY = 0.5

Expand Down Expand Up @@ -446,8 +451,11 @@ def upload(wav_data, metadata):
DatasetApi().upload_wake_word(wav_data,
metadata,
upload_url=upload_url)

Thread(target=upload, daemon=True, args=(wav_data, metadata)).start()
if DatasetApi is not None:
Thread(target=upload, daemon=True,
args=(wav_data, metadata)).start()
else:
LOG.debug("`pip install ovos-backend-client` to enable upload")

@staticmethod
def _compile_ww_context(key_phrase, ww_module):
Expand Down Expand Up @@ -587,13 +595,13 @@ def _upload_stt(self, wav_data, metadata):
upload_url = Configuration().get("listener", {}).get('stt_upload', {}).get('url')

def upload(wav_data, metadata):
# TODO - not yet merged in backend-client
try:
DatasetApi().upload_stt(wav_data, metadata, upload_url=upload_url)
except:
pass
DatasetApi().upload_stt(wav_data, metadata, upload_url=upload_url)

Thread(target=upload, daemon=True, args=(wav_data, metadata)).start()
if DatasetApi:
Thread(target=upload, daemon=True,
args=(wav_data, metadata)).start()
else:
LOG.debug("`pip install ovos-backend-client` to enable upload")

def _stt_audio(self, audio_bytes: bytes, stt_context: dict):
try:
Expand Down
5 changes: 5 additions & 0 deletions requirements/extras.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ovos-backend-client>=0.1.0a7
ovos-microphone-plugin-alsa~=0.0.0
ovos-stt-plugin-server~=0.0.3
ovos-ww-plugin-precise-lite~=0.1
ovos-vad-plugin-webrtcvad~=0.0.1
Copy link
Member

@JarbasAl JarbasAl Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Want to make this one optional too, pending a new plugin based on noise threshold only like original listener

If we are adding an extra with new deps, it should be silero instead, if it's an extra it's fine

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled the default from ovos-config default configuration; I don't have a strong preference between the 2 plugins but I think the extras should make things work without extra config

Copy link
Member

@goldyfruit goldyfruit Oct 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

silero requires onnxruntime or tflite-runtime (don't remember which one), webrtcvad would be more simple to install.

2 changes: 0 additions & 2 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
ovos-backend-client>=0.1.0a7
ovos-plugin-manager>=0.0.24a6
ovos-microphone-plugin-alsa~=0.0.0
ovos-utils>=0.0.36a3
ovos-config~=0.0.10
ovos-bus-client~=0.0.3
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def get_description():
package_data={'': package_files('ovos_dinkum_listener')},
include_package_data=True,
install_requires=required('requirements/requirements.txt'),
extras_require={
"extras": required("requirements/extras.txt")
},
classifiers=[
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
Expand Down
Loading