Skip to content

Commit

Permalink
Add get_tts timing context in execute
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Oct 2, 2023
1 parent 32bf5a4 commit 951a08d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion neon_audio/tts/neon.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

from neon_utils.file_utils import encode_file_to_base64_string
from neon_utils.message_utils import resolve_message
from neon_utils.metrics_utils import Stopwatch
from neon_utils.signal_utils import create_signal, check_for_signal,\
init_signal_bus
from ovos_utils.log import LOG
Expand Down Expand Up @@ -159,6 +160,8 @@ def _play(self):


class WrappedTTS(TTS):
_stopwatch = Stopwatch("get_tts")

def __new__(cls, base_engine, *args, **kwargs):
base_engine.execute = cls.execute
base_engine.get_multiple_tts = cls.get_multiple_tts
Expand Down Expand Up @@ -311,7 +314,10 @@ def execute(self, sentence: str, ident: str = None, listen: bool = False,
create_signal("isSpeaking")
# TODO: Should sentence and ident be added to message context? DM
message.data["text"] = sentence
responses = self.get_multiple_tts(message, **kwargs)
with self._stopwatch:
responses = self.get_multiple_tts(message, **kwargs)
message.context.setdefault('timing', dict())
message.context['timing']['get_tts'] = self._stopwatch.time
LOG.debug(f"responses={responses}")

ident = message.data.get('speak_ident') or ident
Expand Down

0 comments on commit 951a08d

Please sign in to comment.