Skip to content

Commit

Permalink
Add get_tts timing context
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Oct 2, 2023
1 parent 6ab3066 commit 32bf5a4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion neon_audio/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from ovos_utils.log import LOG
from neon_audio.tts import TTSFactory
from neon_utils.messagebus_utils import get_messagebus
from neon_utils.metrics_utils import Stopwatch
from ovos_audio.service import PlaybackService

ovos_audio.tts.TTSFactory = TTSFactory
Expand Down Expand Up @@ -60,6 +61,8 @@ def on_started():


class NeonPlaybackService(PlaybackService):
_stopwatch = Stopwatch("get_tts")

def __init__(self, ready_hook=on_ready, error_hook=on_error,
stopping_hook=on_stopping, alive_hook=on_alive,
started_hook=on_started, watchdog=lambda: None,
Expand Down Expand Up @@ -143,7 +146,10 @@ def handle_get_tts(self, message):
ident, data={"error": f"text is not a str: {text}"}))
return
try:
responses = self.tts.get_multiple_tts(message)
with self._stopwatch:
responses = self.tts.get_multiple_tts(message)
message.context.setdefault('timing', dict())
message.context['timing']['get_tts'] = self._stopwatch.time
LOG.debug(f"Emitting response: {responses}")
self.bus.emit(message.reply(ident, data=responses))
except Exception as e:
Expand Down

0 comments on commit 32bf5a4

Please sign in to comment.