From de02c194d38b581c7d24a07b11be6c42ab8536d1 Mon Sep 17 00:00:00 2001 From: Psychokiller1888 Date: Sun, 16 Apr 2023 12:18:25 +0200 Subject: [PATCH] don't try to play a broken audio file --- core/voice/model/Tts.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/voice/model/Tts.py b/core/voice/model/Tts.py index 3392c96c..81eb6e33 100644 --- a/core/voice/model/Tts.py +++ b/core/voice/model/Tts.py @@ -180,13 +180,6 @@ def _speak(self, file: Path, session: DialogSession): self._speaking = True session.lastWasSoundPlayOnly = False - self.MqttManager.playSound( - soundFilename=file.stem, - location=file.parent, - sessionId=session.sessionId, - deviceUid=session.deviceUid - ) - try: duration = round(len(AudioSegment.from_file(file)) / 1000, 2) except CouldntDecodeError: @@ -195,10 +188,16 @@ def _speak(self, file: Path, session: DialogSession): self.onSay(session) else: self.DialogManager.increaseSessionTimeout(session=session, interval=duration + 1) - if session.deviceUid == self.DeviceManager.getMainDevice().uid: self.ThreadManager.doLater(interval=duration + 0.2, func=self._sayFinished, args=[session]) + self.MqttManager.playSound( + soundFilename=file.stem, + location=file.parent, + sessionId=session.sessionId, + deviceUid=session.deviceUid + ) + def _sayFinished(self, session: DialogSession): self._speaking = False