2017-10-04 06:28:44 +00:00
|
|
|
# Copyright 2017 Mycroft AI Inc.
|
2016-05-26 16:16:13 +00:00
|
|
|
#
|
2017-10-04 06:28:44 +00:00
|
|
|
# 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
|
2016-05-26 16:16:13 +00:00
|
|
|
#
|
2017-10-04 06:28:44 +00:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2016-05-26 16:16:13 +00:00
|
|
|
#
|
2017-10-04 06:28:44 +00:00
|
|
|
# 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.
|
2016-05-26 16:16:13 +00:00
|
|
|
#
|
2020-02-10 10:09:56 +00:00
|
|
|
"""Mycroft util library.
|
|
|
|
|
|
|
|
A collections of utils and tools for making skill development easier.
|
|
|
|
"""
|
2018-04-03 14:50:53 +00:00
|
|
|
from __future__ import absolute_import
|
2019-08-27 15:20:43 +00:00
|
|
|
|
2019-09-13 19:02:27 +00:00
|
|
|
import os
|
2018-04-03 14:50:53 +00:00
|
|
|
|
2017-06-15 13:50:43 +00:00
|
|
|
import mycroft.audio
|
2018-01-31 11:31:16 +00:00
|
|
|
from mycroft.util.format import nice_number
|
2020-03-08 16:40:24 +00:00
|
|
|
from .string_utils import get_http, remove_last_slash, camel_case_split
|
|
|
|
from .audio_utils import (play_audio_file, play_wav, play_ogg, play_mp3,
|
|
|
|
record, find_input_device)
|
|
|
|
from .file_utils import (resolve_resource_file, read_stripped_lines, read_dict,
|
|
|
|
create_file, ensure_directory_exists,
|
|
|
|
curate_cache, get_cache_directory)
|
|
|
|
from .network_utils import connected
|
|
|
|
from .process_utils import (reset_sigint_handler, create_daemon,
|
|
|
|
wait_for_exit_signal, create_echo_function)
|
|
|
|
from .log import LOG
|
|
|
|
from .parse import extract_datetime, extract_number, normalize
|
|
|
|
from .signal import check_for_signal, create_signal, get_ipc_directory
|
|
|
|
from .platform import get_arch
|
2016-09-22 18:16:11 +00:00
|
|
|
|
|
|
|
|
2017-06-07 10:00:29 +00:00
|
|
|
def is_speaking():
|
|
|
|
"""Determine if Text to Speech is occurring
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
bool: True while still speaking
|
|
|
|
"""
|
2017-09-18 18:55:58 +00:00
|
|
|
LOG.info("mycroft.utils.is_speaking() is depreciated, use "
|
2017-09-18 19:14:21 +00:00
|
|
|
"mycroft.audio.is_speaking() instead.")
|
2017-06-15 13:50:43 +00:00
|
|
|
return mycroft.audio.is_speaking()
|
2017-06-07 10:00:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
"""
|
2017-09-18 18:55:58 +00:00
|
|
|
LOG.info("mycroft.utils.wait_while_speaking() is depreciated, use "
|
2017-09-18 19:14:21 +00:00
|
|
|
"mycroft.audio.wait_while_speaking() instead.")
|
2017-06-15 13:50:43 +00:00
|
|
|
return mycroft.audio.wait_while_speaking()
|
2017-06-12 07:57:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
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
|
2017-09-18 18:55:58 +00:00
|
|
|
LOG.info("mycroft.utils.stop_speaking() is depreciated, use "
|
2017-09-18 19:14:21 +00:00
|
|
|
"mycroft.audio.stop_speaking() instead.")
|
2017-06-15 13:50:43 +00:00
|
|
|
mycroft.audio.stop_speaking()
|