Skip to content

Commit

Permalink
don't try to play a broken audio file
Browse files Browse the repository at this point in the history
  • Loading branch information
Psychokiller1888 committed Apr 16, 2023
1 parent a9d4522 commit de02c19
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions core/voice/model/Tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit de02c19

Please sign in to comment.