Skip to content

Commit

Permalink
Merge branch 'rhasspy:master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
llluis authored Feb 2, 2024
2 parents 0ce79f5 + 8850100 commit 0b1c9bc
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
!script/setup
!script/run
!wyoming_satellite/*.py
!wyoming_satellite/utils
!wyoming_satellite/VERSION
!docker/run
!sounds/*.wav
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)
* `--tts-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
2 changes: 1 addition & 1 deletion script/build_docker
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
docker buildx build . \
docker build . \
-t 'rhasspy/wyoming-satellite' "$@"
2 changes: 1 addition & 1 deletion wyoming_satellite/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.2.0
18 changes: 18 additions & 0 deletions wyoming_satellite/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,17 @@ async def main() -> None:
"--mic-noise-suppression", type=int, default=0, choices=(0, 1, 2, 3, 4)
)
parser.add_argument("--mic-auto-gain", type=int, default=0, choices=list(range(32)))
parser.add_argument(
"--mic-seconds-to-mute-after-awake-wav",
type=float,
default=0.5,
help="Seconds to mute microphone after awake wav is finished playing (default: 0.5)",
)
parser.add_argument(
"--mic-no-mute-during-awake-wav",
action="store_true",
help="Don't mute the microphone while awake wav is being played",
)

# Sound output
parser.add_argument("--snd-uri", help="URI of Wyoming sound service")
Expand Down Expand Up @@ -182,6 +193,10 @@ async def main() -> None:
"--tts-stop-command",
help="Command to run when text to speech response stops",
)
parser.add_argument(
"--tts-played-command",
help="Command to run when text-to-speech audio stopped playing",
)
parser.add_argument(
"--streaming-start-command",
help="Command to run when audio streaming starts",
Expand Down Expand Up @@ -301,6 +316,8 @@ async def main() -> None:
volume_multiplier=args.mic_volume_multiplier,
auto_gain=args.mic_auto_gain,
noise_suppression=args.mic_noise_suppression,
seconds_to_mute_after_awake_wav=args.mic_seconds_to_mute_after_awake_wav,
mute_during_awake_wav=(not args.mic_no_mute_during_awake_wav),
),
vad=VadSettings(
enabled=args.vad,
Expand Down Expand Up @@ -334,6 +351,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.tts_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
9 changes: 7 additions & 2 deletions wyoming_satellite/satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
StreamingStarted,
StreamingStopped,
)
from wyoming.snd import SndProcessAsyncClient, Played
from wyoming.snd import Played, SndProcessAsyncClient
from wyoming.tts import Synthesize
from wyoming.vad import VoiceStarted, VoiceStopped
from wyoming.wake import Detect, Detection, WakeProcessAsyncClient
Expand Down Expand Up @@ -558,7 +558,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 @@ -784,6 +784,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

0 comments on commit 0b1c9bc

Please sign in to comment.