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

Expose Played command #94

Merged
merged 3 commits into from
Jan 30, 2024
Merged
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ Satellites can respond to events from the server by running commands:
* `--stt-start-command` - user started speaking (no stdin)
* `--stt-stop-command` - user stopped speaking (no stdin)
* `--synthesize-command` - text-to-speech text is returned (text on stdin)
* `--tts-start-command` - text-to-speech response started (no stdin)
* `--tts-stop-command` - text-to-speech response stopped (no stdin)
* `--tts-start-command` - text-to-speech response started streaming from server (no stdin)
* `--tts-stop-command` - text-to-speech response stopped streaming from server. Can still being played by snd service (no stdin)
* `--played-command` - text-to-speech audio finished playing (no stdin)
* `--error-command` - an error was sent from the server (text on stdin)
* `--connected-command` - satellite connected to server
* `--disconnected-command` - satellite disconnected from server
Expand Down
4 changes: 4 additions & 0 deletions wyoming_satellite/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ async def main() -> None:
parser.add_argument(
"--detection-command", help="Command to run when wake word is detected"
)
parser.add_argument(
"--played-command", help="Command to run when audio stopped playing"
)
parser.add_argument(
"--transcript-command",
help="Command to run when speech to text transcript is returned",
Expand Down Expand Up @@ -334,6 +337,7 @@ async def main() -> None:
streaming_stop=split_command(args.streaming_stop_command),
detect=split_command(args.detect_command),
detection=split_command(args.detection_command),
played=split_command(args.played_command),
transcript=split_command(args.transcript_command),
stt_start=split_command(args.stt_start_command),
stt_stop=split_command(args.stt_stop_command),
Expand Down
7 changes: 6 additions & 1 deletion wyoming_satellite/satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ async def _disconnect() -> None:
event.type
):
await _disconnect()
await self.forward_event(Played().event())
await self.trigger_played()
snd_client = None # reconnect on next event
except asyncio.CancelledError:
break
Expand Down Expand Up @@ -775,6 +775,11 @@ async def trigger_detection(self, detection: Detection) -> None:
mute_microphone=self.settings.mic.mute_during_awake_wav,
)

async def trigger_played(self) -> None:
"""Called when audio stopped playing"""
await run_event_command(self.settings.event.played)
await self.forward_event(Played().event())

async def trigger_transcript(self, transcript: Transcript) -> None:
"""Called when speech-to-text text is received."""
await run_event_command(self.settings.event.transcript, transcript.text)
Expand Down
1 change: 1 addition & 0 deletions wyoming_satellite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class EventSettings(ServiceSettings):
streaming_stop: Optional[List[str]] = None
detect: Optional[List[str]] = None
detection: Optional[List[str]] = None
played: Optional[List[str]] = None
transcript: Optional[List[str]] = None
stt_start: Optional[List[str]] = None
stt_stop: Optional[List[str]] = None
Expand Down
Loading