Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change event order most frequent to lease, all elif, upgrade to wyoming 1.6.0 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.2.1

- change order og events to most frequent to least, all elif after 1st, stop after found
- uprgade to wyoming 1.6.0
- remove return False after AudioStop as it kills server, have to restart for next process

## 1.2.0

- Upgrade to wyoming 1.5.3
Expand Down
24 changes: 11 additions & 13 deletions wyoming_porcupine1/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,8 @@ def __init__(
_LOGGER.debug("Client connected: %s", self.client_id)

async def handle_event(self, event: Event) -> bool:
if Describe.is_type(event.type):
await self.write_event(self.wyoming_info_event)
_LOGGER.debug("Sent info to client: %s", self.client_id)
return True

if Detect.is_type(event.type):
detect = Detect.from_event(event)
if detect.names:
# TODO: use all names
await self._load_keyword(detect.names[0])
elif AudioStart.is_type(event.type):
self.detected = False
elif AudioChunk.is_type(event.type):
if AudioChunk.is_type(event.type):
if self.detector is None:
# Default keyword
await self._load_keyword(DEFAULT_KEYWORD)
Expand Down Expand Up @@ -260,8 +249,17 @@ async def handle_event(self, event: Event) -> bool:
_LOGGER.debug(
"Audio stopped without detection from client: %s", self.client_id
)
elif AudioStart.is_type(event.type):
self.detected = False

return False
elif Detect.is_type(event.type):
detect = Detect.from_event(event)
if detect.names:
# TODO: use all names
await self._load_keyword(detect.names[0])
elif Describe.is_type(event.type):
await self.write_event(self.wyoming_info_event)
_LOGGER.debug("Sent info to client: %s", self.client_id)
else:
_LOGGER.debug("Unexpected event: type=%s, data=%s", event.type, event.data)

Expand Down