Skip to content

Commit

Permalink
Add timing metrics for audio input to handler in speech service
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Nov 10, 2023
1 parent 588721b commit b11a5e9
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 b11a5e9

Please sign in to comment.