Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jayeshp19 committed Jan 13, 2025
1 parent 660d783 commit 81e2ebd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
11 changes: 9 additions & 2 deletions livekit-plugins/livekit-plugins-aws/livekit/plugins/aws/stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,16 @@ async def input_generator():
except Exception as e:
logger.exception(f"an error occurred while streaming inputs: {e}")

# try to connect
handler = TranscriptEventHandler(stream.output_stream, self._event_ch)
await asyncio.gather(input_generator(), handler.handle_events())
tasks = [
asyncio.create_task(input_generator()),
asyncio.create_task(handler.handle_events()),
]
# try to connect
try:
await asyncio.gather(*tasks)
finally:
await utils.aio.gracefully_cancel(*tasks)
except Exception as e:
logger.exception(f"an error occurred while streaming inputs: {e}")

Expand Down
6 changes: 3 additions & 3 deletions tests/test_stt.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ async def _stream_output():

async for event in stream:
if event.type == agents.stt.SpeechEventType.START_OF_SPEECH:
assert (
recv_end
), "START_OF_SPEECH recv but no END_OF_SPEECH has been sent before"
assert recv_end, (
"START_OF_SPEECH recv but no END_OF_SPEECH has been sent before"
)
assert not recv_start
recv_end = False
recv_start = True
Expand Down
22 changes: 10 additions & 12 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,16 @@


def wer(hypothesis: str, reference: str) -> float:
wer_standardize_contiguous = tr.Compose(
[
tr.ToLowerCase(),
tr.ExpandCommonEnglishContractions(),
tr.RemoveKaldiNonWords(),
tr.RemoveWhiteSpace(replace_by_space=True),
tr.RemoveMultipleSpaces(),
tr.Strip(),
tr.ReduceToSingleSentence(),
tr.ReduceToListOfListOfWords(),
]
)
wer_standardize_contiguous = tr.Compose([
tr.ToLowerCase(),
tr.ExpandCommonEnglishContractions(),
tr.RemoveKaldiNonWords(),
tr.RemoveWhiteSpace(replace_by_space=True),
tr.RemoveMultipleSpaces(),
tr.Strip(),
tr.ReduceToSingleSentence(),
tr.ReduceToListOfListOfWords(),
])

return tr.wer(
reference,
Expand Down

0 comments on commit 81e2ebd

Please sign in to comment.