2017-10-04 06:28:44 +00:00
|
|
|
# Copyright 2017 Mycroft AI Inc.
|
2017-02-09 11:09:56 +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
|
2017-02-09 11:09:56 +00:00
|
|
|
#
|
2017-10-04 06:28:44 +00:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2017-02-09 11:09:56 +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.
|
2017-02-09 11:09:56 +00:00
|
|
|
#
|
2017-11-02 12:22:26 +00:00
|
|
|
"""
|
|
|
|
Mycroft audio service.
|
|
|
|
|
|
|
|
This handles playback of audio and speech
|
|
|
|
"""
|
2017-09-23 12:13:50 +00:00
|
|
|
from mycroft.configuration import Configuration
|
2019-07-15 22:36:43 +00:00
|
|
|
from mycroft.messagebus.client import MessageBusClient
|
2018-04-03 14:50:53 +00:00
|
|
|
from mycroft.util import reset_sigint_handler, wait_for_exit_signal, \
|
2018-08-15 03:07:59 +00:00
|
|
|
create_daemon, create_echo_function, check_for_signal
|
2017-09-18 18:55:58 +00:00
|
|
|
from mycroft.util.log import LOG
|
2017-02-09 11:09:56 +00:00
|
|
|
|
2018-08-16 14:17:41 +00:00
|
|
|
import mycroft.audio.speech as speech
|
|
|
|
from .audioservice import AudioService
|
2018-03-17 16:25:49 +00:00
|
|
|
|
2017-02-09 11:09:56 +00:00
|
|
|
|
|
|
|
def main():
|
2017-11-02 12:22:26 +00:00
|
|
|
""" Main function. Run when file is invoked. """
|
2018-04-03 14:50:53 +00:00
|
|
|
reset_sigint_handler()
|
2018-08-15 03:07:59 +00:00
|
|
|
check_for_signal("isSpeaking")
|
2019-07-15 22:36:43 +00:00
|
|
|
bus = MessageBusClient() # Connect to the Mycroft Messagebus
|
2019-07-26 06:53:27 +00:00
|
|
|
Configuration.set_config_update_handlers(bus)
|
2018-08-22 01:50:50 +00:00
|
|
|
speech.init(bus)
|
2017-02-09 11:09:56 +00:00
|
|
|
|
2018-04-03 14:50:53 +00:00
|
|
|
LOG.info("Starting Audio Services")
|
2018-08-22 01:50:50 +00:00
|
|
|
bus.on('message', create_echo_function('AUDIO', ['mycroft.audio.service']))
|
|
|
|
audio = AudioService(bus) # Connect audio service instance to message bus
|
|
|
|
create_daemon(bus.run_forever)
|
2018-04-03 14:50:53 +00:00
|
|
|
|
|
|
|
wait_for_exit_signal()
|
|
|
|
|
|
|
|
speech.shutdown()
|
|
|
|
audio.shutdown()
|
2017-02-09 11:09:56 +00:00
|
|
|
|
|
|
|
|
2018-08-16 14:17:41 +00:00
|
|
|
main()
|