expose played command

This commit is contained in:
Luis Andrade
2024-01-28 22:53:37 -05:00
parent 20bbd3cb4f
commit 366547c457
3 changed files with 11 additions and 1 deletions
+4
View File
@@ -158,6 +158,9 @@ async def main() -> None:
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"
) )
parser.add_argument(
"--played-command", help="Command to run when audio stopped playing"
)
parser.add_argument( parser.add_argument(
"--transcript-command", "--transcript-command",
help="Command to run when speech to text transcript is returned", help="Command to run when speech to text transcript is returned",
@@ -334,6 +337,7 @@ async def main() -> None:
streaming_stop=split_command(args.streaming_stop_command), streaming_stop=split_command(args.streaming_stop_command),
detect=split_command(args.detect_command), detect=split_command(args.detect_command),
detection=split_command(args.detection_command), detection=split_command(args.detection_command),
played=split_command(args.played_command),
transcript=split_command(args.transcript_command), transcript=split_command(args.transcript_command),
stt_start=split_command(args.stt_start_command), stt_start=split_command(args.stt_start_command),
stt_stop=split_command(args.stt_stop_command), stt_stop=split_command(args.stt_stop_command),
+6 -1
View File
@@ -550,7 +550,7 @@ class SatelliteBase:
event.type event.type
): ):
await _disconnect() await _disconnect()
await self.forward_event(Played().event()) await self.trigger_played()
snd_client = None # reconnect on next event snd_client = None # reconnect on next event
except asyncio.CancelledError: except asyncio.CancelledError:
break break
@@ -775,6 +775,11 @@ class SatelliteBase:
mute_microphone=self.settings.mic.mute_during_awake_wav, 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: async def trigger_transcript(self, transcript: Transcript) -> None:
"""Called when speech-to-text text is received.""" """Called when speech-to-text text is received."""
await run_event_command(self.settings.event.transcript, transcript.text) await run_event_command(self.settings.event.transcript, transcript.text)
+1
View File
@@ -149,6 +149,7 @@ class EventSettings(ServiceSettings):
streaming_stop: Optional[List[str]] = None streaming_stop: Optional[List[str]] = None
detect: Optional[List[str]] = None detect: Optional[List[str]] = None
detection: Optional[List[str]] = None detection: Optional[List[str]] = None
played: Optional[List[str]] = None
transcript: Optional[List[str]] = None transcript: Optional[List[str]] = None
stt_start: Optional[List[str]] = None stt_start: Optional[List[str]] = None
stt_stop: Optional[List[str]] = None stt_stop: Optional[List[str]] = None