Skip to content

Commit

Permalink
Add timing metrics for audio input to handler in speech service (#181)
Browse files Browse the repository at this point in the history
# Description
Handles `client_sent` timestamp and calculates how long it took for the
message to be handled in this module

# Issues
<!-- If this is related to or closes an issue/other PR, please note them
here -->

# Other Notes
NeonGeckoCom/neon_audio#154

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Nov 10, 2023
1 parent 588721b commit b8917d8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions neon_speech/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ def build_context(msg: Message):
'transcribed': time()}}
return ctx

received_time = time()
sent_time = message.context.get("timing", {}).get("client_sent",
received_time)
ident = message.context.get("ident") or "neon.audio_input.response"
LOG.info(f"Handling audio input: {ident}")
if message.data.get("audio_data"):
Expand All @@ -385,10 +388,13 @@ def build_context(msg: Message):
lang = message.data.get("lang")
try:
with self._stopwatch:
# _=transformed audio_data
_, parser_data, transcriptions = \
self._get_stt_from_file(wav_file_path, lang)
message.context["audio_parser_data"] = parser_data
context = build_context(message)
if received_time != sent_time:
context['timing']['mq_from_client'] = received_time - sent_time
context['timing']['get_stt'] = self._stopwatch.time
data = {
"utterances": transcriptions,
Expand Down

0 comments on commit b8917d8

Please sign in to comment.