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

refactor/opm #39

Closed
wants to merge 14 commits into from
Closed
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
45 changes: 1 addition & 44 deletions neon_audio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,5 @@
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from mycroft.audio.utils import wait_while_speaking, is_speaking, stop_speaking
NeonDaniel marked this conversation as resolved.
Show resolved Hide resolved

import time
from ovos_utils.signal import check_for_signal, create_signal
from neon_utils.configuration_utils import get_neon_local_config


IPC_PATH = get_neon_local_config().get("dirVars", {}).get("ipcDir", "/tmp/neon/ipc")
CONFIG = {"ipc_path": IPC_PATH}


def is_speaking():
"""Determine if Text to Speech is occurring

Returns:
bool: True while still speaking
"""
return check_for_signal("isSpeaking", -1, CONFIG)


def wait_while_speaking():
"""Pause as long as Text to Speech is still happening

Pause while Text to Speech is still happening. This always pauses
briefly to ensure that any preceeding request to speak has time to
begin.
"""
# TODO: Better method using messages or signals here DM
time.sleep(0.3) # Wait briefly in for any queued speech to begin
while is_speaking():
time.sleep(0.1)


def stop_speaking():
# TODO: Less hacky approach to this once Audio Manager is implemented
# Skills should only be able to stop speech they've initiated
from mycroft_bus_client.send_func import send
create_signal('stoppingTTS')
send('mycroft.audio.speech.stop')

# Block until stopped
while check_for_signal("isSpeaking", -1, CONFIG):
time.sleep(0.25)

# This consumes the signal
check_for_signal('stoppingTTS', CONFIG)
5 changes: 2 additions & 3 deletions neon_audio/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
from neon_utils.logger import LOG

from neon_audio import speech
from neon_audio.audioservice import AudioService

from mycroft.audio.audioservice import AudioService
from mycroft.util.process_utils import ProcessStatus, StatusCallbackMap, start_message_bus_client
from mycroft.util import reset_sigint_handler, wait_for_exit_signal, check_for_signal

Expand Down Expand Up @@ -62,7 +61,7 @@ def main(ready_hook=on_ready, error_hook=on_error, stopping_hook=on_stopping, co
if get_neon_device_type() == 'server':
audio = None
else:
audio = AudioService(bus, config) # Connect audio service instance to message bus
audio = AudioService(bus) # Connect audio service instance to message bus
Copy link
Member

Choose a reason for hiding this comment

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

Probably need a call to export config if we're not passing it directly here


status.set_started()
except Exception as e:
Expand Down
Loading