scripts/mycroft/audio/__init__.py
Go to the documentation of this file.
1 # Copyright 2017 Mycroft AI Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 import time
16 
17 from mycroft.util.signal import check_for_signal, create_signal
18 
19 
21  """Determine if Text to Speech is occurring
22 
23  Returns:
24  bool: True while still speaking
25  """
26  return check_for_signal("isSpeaking", -1)
27 
28 
30  """Pause as long as Text to Speech is still happening
31 
32  Pause while Text to Speech is still happening. This always pauses
33  briefly to ensure that any preceeding request to speak has time to
34  begin.
35  """
36  time.sleep(0.3) # Wait briefly in for any queued speech to begin
37  while is_speaking():
38  time.sleep(0.1)
39 
40 
42  # TODO: Less hacky approach to this once Audio Manager is implemented
43  # Skills should only be able to stop speech they've initiated
44  from mycroft.messagebus.send import send
45  create_signal('stoppingTTS')
46  send('mycroft.audio.speech.stop')
47 
48  # Block until stopped
49  while check_for_signal("isSpeaking", -1):
50  time.sleep(0.25)
51 
52  # This consumes the signal
53  check_for_signal('stoppingTTS')
def check_for_signal(signal_name, sec_lifetime=0)
Definition: signal.py:105
def create_signal(signal_name)
Definition: signal.py:90
def send(messageToSend, dataToSend=None)
Definition: send.py:57


mycroft_ros
Author(s):
autogenerated on Mon Apr 26 2021 02:35:40