Add empty tts output on execute exception
This will make sure that the isSpeaking flag is cleared correctly
@@ -51,6 +51,7 @@ class PlaybackThread(Thread):
self._terminated = False
self._processing_queue = False
self.enclosure = None
+ self.p = None
# Check if the tts shall have a ducking role set
if Configuration.get().get('tts', {}).get('pulse_duck'):
self.pulse_env = _TTS_ENV
@@ -102,6 +103,7 @@ class PlaybackThread(Thread):
self.p = play_mp3(data, environment=self.pulse_env)
if visemes:
self.show_visemes(visemes)
+ if self.p:
self.p.communicate()
self.p.wait()
report_timing(ident, 'speech_playback', stopwatch)
@@ -312,6 +314,13 @@ class TTS(metaclass=ABCMeta):
sentence = self.validate_ssml(sentence)
create_signal("isSpeaking")
+ try:
+ self._execute(sentence, ident, listen)
+ except Exception:
+ # If an error occurs end the audio sequence
+ self.queue.put((None, None, None, None, None))
+
+ def _execute(self, sentence, ident, listen):
if self.phonetic_spelling:
for word in re.findall(r"[\w']+", sentence):
if word.lower() in self.spellings:
