Add --detect-command
This commit is contained in:
@@ -130,6 +130,7 @@ You can also use `--mic-volume-multiplier X` to multiply all audio samples by `X
|
|||||||
|
|
||||||
Satellites can respond to events from the server by running commands:
|
Satellites can respond to events from the server by running commands:
|
||||||
|
|
||||||
|
* `--detect-command` - wake word detection has started, but not detected yet (no stdin)
|
||||||
* `--streaming-start-command` - audio has started streaming to server
|
* `--streaming-start-command` - audio has started streaming to server
|
||||||
* `--detection-command` - wake word is detected (wake word name on stdin)
|
* `--detection-command` - wake word is detected (wake word name on stdin)
|
||||||
* `--transcript-command` - speech-to-text transcript is returned (text on stdin)
|
* `--transcript-command` - speech-to-text transcript is returned (text on stdin)
|
||||||
@@ -138,5 +139,6 @@ Satellites can respond to events from the server by running commands:
|
|||||||
* `--synthesize-command` - text-to-speech text is returned (text on stdin)
|
* `--synthesize-command` - text-to-speech text is returned (text on stdin)
|
||||||
* `--tts-start-command` - text-to-speech response started (no stdin)
|
* `--tts-start-command` - text-to-speech response started (no stdin)
|
||||||
* `--tts-stop-command` - text-to-speech response stopped (no stdin)
|
* `--tts-stop-command` - text-to-speech response stopped (no stdin)
|
||||||
|
* `--error-command` - an error was sent from the server (text on stdin)
|
||||||
|
|
||||||
For more advanced scenarios, use an event service (`--event-uri`). See `wyoming_satellite/example_event_client.py` for a basic client that just logs events.
|
For more advanced scenarios, use an event service (`--event-uri`). See `wyoming_satellite/example_event_client.py` for a basic client that just logs events.
|
||||||
|
|||||||
@@ -145,6 +145,9 @@ async def main() -> None:
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--event-uri", help="URI of Wyoming service to forward events to"
|
"--event-uri", help="URI of Wyoming service to forward events to"
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--detect-command", help="Command to run when wake word detection starts"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--detection-command", help="Command to run when wake word is detected"
|
"--detection-command", help="Command to run when wake word is detected"
|
||||||
)
|
)
|
||||||
@@ -176,6 +179,10 @@ async def main() -> None:
|
|||||||
"--streaming-start-command",
|
"--streaming-start-command",
|
||||||
help="Command to run when audio streaming starts",
|
help="Command to run when audio streaming starts",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--error-command",
|
||||||
|
help="Command to run when an error occurs",
|
||||||
|
)
|
||||||
|
|
||||||
# Sounds
|
# Sounds
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -199,6 +206,10 @@ async def main() -> None:
|
|||||||
"--zeroconf-name",
|
"--zeroconf-name",
|
||||||
help="Name used for zeroconf discovery (default: MAC from uuid.getnode)",
|
help="Name used for zeroconf discovery (default: MAC from uuid.getnode)",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--zeroconf-host",
|
||||||
|
help="Host address for zeroconf discovery (default: detect)",
|
||||||
|
)
|
||||||
#
|
#
|
||||||
parser.add_argument("--debug", action="store_true", help="Log DEBUG messages")
|
parser.add_argument("--debug", action="store_true", help="Log DEBUG messages")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
@@ -261,9 +272,13 @@ async def main() -> None:
|
|||||||
await register_server(
|
await register_server(
|
||||||
name=args.zeroconf_name,
|
name=args.zeroconf_name,
|
||||||
port=tcp_server.port,
|
port=tcp_server.port,
|
||||||
host=tcp_server.host,
|
host=args.zeroconf_host,
|
||||||
|
)
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Zeroconf discovery enabled (name=%s, host=%s)",
|
||||||
|
args.zeroconf_name,
|
||||||
|
args.zeroconf_host,
|
||||||
)
|
)
|
||||||
_LOGGER.debug("Zeroconf discovery enabled (name=%s)", args.zeroconf_name)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await server.run(partial(SatelliteEventHandler, wyoming_info, args))
|
await server.run(partial(SatelliteEventHandler, wyoming_info, args))
|
||||||
@@ -699,7 +714,10 @@ class SatelliteEventHandler(AsyncEventHandler):
|
|||||||
|
|
||||||
async def _forward_event(self, event: Event) -> None:
|
async def _forward_event(self, event: Event) -> None:
|
||||||
"""Forward a Wyoming event to a client and run event commands."""
|
"""Forward a Wyoming event to a client and run event commands."""
|
||||||
if self.cli_args.detection_command and Detection.is_type(event.type):
|
if self.cli_args.detect_command and Detect.is_type(event.type):
|
||||||
|
# Wake word detection started
|
||||||
|
await self._run_event_command(self.cli_args.detect_command)
|
||||||
|
elif self.cli_args.detection_command and Detection.is_type(event.type):
|
||||||
# Wake word is detected
|
# Wake word is detected
|
||||||
detection = Detection.from_event(event)
|
detection = Detection.from_event(event)
|
||||||
await self._run_event_command(
|
await self._run_event_command(
|
||||||
@@ -729,6 +747,10 @@ class SatelliteEventHandler(AsyncEventHandler):
|
|||||||
elif self.cli_args.tts_stop_command and AudioStop.is_type(event.type):
|
elif self.cli_args.tts_stop_command and AudioStop.is_type(event.type):
|
||||||
# TTS audio stop
|
# TTS audio stop
|
||||||
await self._run_event_command(self.cli_args.tts_stop_command)
|
await self._run_event_command(self.cli_args.tts_stop_command)
|
||||||
|
elif self.cli_args.error_command and Error.is_type(event.type):
|
||||||
|
# Error occurred
|
||||||
|
error = Error.from_event(event)
|
||||||
|
await self._run_event_command(self.cli_args.error_command, error.text)
|
||||||
|
|
||||||
if not self.cli_args.event_uri:
|
if not self.cli_args.event_uri:
|
||||||
# No external service
|
# No external service
|
||||||
|
|||||||
Reference in New Issue
Block a user