@@ -133,6 +133,19 @@ def get_requested_tts_languages(msg) -> list:
133
133
return tts_reqs
134
134
135
135
136
+ def _sort_timing_metrics (timings : dict ) -> dict :
137
+ """
138
+ Sort combined timing context into timestamps and durations
139
+ """
140
+ to_return = {"timestamps" : {}, "durations" : {}}
141
+ for key , val in timings :
142
+ if val > 10000.0 : # Arbitrary value that is > longest duration
143
+ to_return ["timestamps" ][key ] = val
144
+ else :
145
+ to_return ["durations" ][key ] = val
146
+ return to_return
147
+
148
+
136
149
class NeonPlaybackThread (PlaybackThread ):
137
150
def __init__ (self , queue , bus = None ):
138
151
LOG .info ("Initializing NeonPlaybackThread" )
@@ -172,8 +185,8 @@ def _play(self):
172
185
message .context ["timestamp" ] = time ()
173
186
self .bus .emit (message .forward ("neon.metric" ,
174
187
{"name" : "local_interaction" ,
175
- "timestamp" : time (),
176
- "timing" : message .context ['timing' ]}))
188
+ ** _sort_timing_metrics (
189
+ message .context ['timing' ]) }))
177
190
178
191
179
192
class WrappedTTS (TTS ):
@@ -369,8 +382,8 @@ def execute(self, sentence: str, ident: str = None, listen: bool = False,
369
382
message .context ["timestamp" ] = time ()
370
383
self .bus .emit (message .forward ("neon.metric" ,
371
384
{"name" : "klat_interaction" ,
372
- "timestamp" : time (),
373
- "timing" : message .context ['timing' ]}))
385
+ ** _sort_timing_metrics (
386
+ message .context ['timing' ]) }))
374
387
else :
375
388
# Local user has multiple configured languages (or genders)
376
389
for r in responses .values ():
0 commit comments