Skip to content

Commit

Permalink
migrate ovos-listener
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Mar 3, 2023
1 parent 831ff7f commit 8585de1
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 2,440 deletions.
536 changes: 3 additions & 533 deletions mycroft/listener/__init__.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mycroft/listener/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from mycroft.listener.service import SpeechService, on_error, on_stopping, on_ready
from ovos_listener.service import SpeechService, on_error, on_stopping, on_ready
from ovos_config.locale import setup_locale
from ovos_utils.log import init_service_logger
from ovos_utils.process_utils import reset_sigint_handler, PIDLock
Expand Down
63 changes: 2 additions & 61 deletions mycroft/listener/data_structures.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,3 @@
# Copyright 2020 Mycroft AI Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
"""Data structures used by the speech client."""
# backwards compat imports
from ovos_listener.data_structures import CyclicAudioBuffer
from mycroft.deprecated.speech_client import RollingMean


class CyclicAudioBuffer:
"""A Cyclic audio buffer for storing binary data.
TODO: The class is still unoptimized and performance can probably be
enhanced.
Args:
size (int): size in bytes
initial_data (bytes): initial buffer data
"""

def __init__(self, size, initial_data):
self.size = size
# Get at most size bytes from the end of the initial data
self._buffer = initial_data[-size:]

def clear(self):
self._buffer = b'\0' * self.size

def append(self, data):
"""Add new data to the buffer, and slide out data if the buffer is full
Args:
data (bytes): binary data to append to the buffer. If buffer size
is exceeded the oldest data will be dropped.
"""
buff = self._buffer + data
if len(buff) > self.size:
buff = buff[-self.size:]
self._buffer = buff

def get(self):
"""Get the binary data."""
return self._buffer

def get_last(self, size):
"""Get the last entries of the buffer."""
return self._buffer[-size:]

def __getitem__(self, key):
return self._buffer[key]

def __len__(self):
return len(self._buffer)
17 changes: 4 additions & 13 deletions mycroft/listener/hotword_factory.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
from ovos_config.config import Configuration
from ovos_plugin_manager.wakewords import OVOSWakeWordFactory, \
load_wake_word_plugin, find_wake_word_plugins
from ovos_plugin_manager.templates.hotwords import HotWordEngine


class HotWordFactory(OVOSWakeWordFactory):
@classmethod
def create_hotword(cls, hotword="hey mycroft", config=None,
lang="en-us", loop=None):
if not config:
config = Configuration()['hotwords']
return OVOSWakeWordFactory.create_hotword(hotword, config, lang, loop)
# backwards compat imports
from ovos_listener.hotword_factory import HotWordFactory
from ovos_plugin_manager.wakewords import load_wake_word_plugin, find_wake_word_plugins
from ovos_plugin_manager.templates.hotwords import HotWordEngine
Loading

0 comments on commit 8585de1

Please sign in to comment.