From 2c13719d952768363e7d7fee4395a01378377c61 Mon Sep 17 00:00:00 2001 From: sam detweiler Date: Sun, 24 Nov 2024 17:10:40 -0600 Subject: [PATCH 1/2] change order of event proocessing for preformance, upgrade to wyoming 1.6.0 --- CHANGELOG.md | 5 +++++ requirements.txt | 2 +- wyoming_snd_external/__main__.py | 14 +++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 216d1db..8d1da38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.0.1 + +- change order of event to most frequent to least +- upgrade to wyoming 1.6.0 + ## 1.0.0 - Initial release diff --git a/requirements.txt b/requirements.txt index 57cebeb..3860bbd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1 @@ -wyoming==1.2.0 +wyoming==1.6.0 diff --git a/wyoming_snd_external/__main__.py b/wyoming_snd_external/__main__.py index 80bdc8a..6d40543 100644 --- a/wyoming_snd_external/__main__.py +++ b/wyoming_snd_external/__main__.py @@ -89,11 +89,8 @@ def __init__( _LOGGER.debug("Client connected: %s", self.client_id) async def handle_event(self, event: Event) -> bool: - if AudioStart.is_type(event.type): - await self._start_proc() - elif AudioStop.is_type(event.type): - await self.write_event(Played().event()) - elif AudioChunk.is_type(event.type): + + if AudioChunk.is_type(event.type): await self._start_proc() chunk = AudioChunk.from_event(event) @@ -105,6 +102,11 @@ async def handle_event(self, event: Event) -> bool: self._proc.stdin.write(chunk.audio) await self._proc.stdin.drain() + elif AudioStop.is_type(event.type): + await self.write_event(Played().event()) + elif AudioStart.is_type(event.type): + await self._start_proc() + return True async def _start_proc(self) -> None: @@ -117,6 +119,8 @@ async def _start_proc(self) -> None: self.command[0], *self.command[1:], stdin=asyncio.subprocess.PIPE ) assert self._proc.stdin is not None + // wait a little til the process starts + await asyncio.sleep(1) async def _stop_proc(self) -> None: if self._proc is None: From e5b6ef289c15870fae78ba2993ed6c2fde7a5a02 Mon Sep 17 00:00:00 2001 From: sam detweiler Date: Mon, 25 Nov 2024 10:42:58 -0600 Subject: [PATCH 2/2] fix js type comment --- wyoming_snd_external/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wyoming_snd_external/__main__.py b/wyoming_snd_external/__main__.py index 6d40543..814a944 100644 --- a/wyoming_snd_external/__main__.py +++ b/wyoming_snd_external/__main__.py @@ -119,7 +119,7 @@ async def _start_proc(self) -> None: self.command[0], *self.command[1:], stdin=asyncio.subprocess.PIPE ) assert self._proc.stdin is not None - // wait a little til the process starts + # wait a little til the process starts await asyncio.sleep(1) async def _stop_proc(self) -> None: