Skip to content

Commit

Permalink
speaker volume
Browse files Browse the repository at this point in the history
  • Loading branch information
llluis committed Feb 12, 2024
1 parent 094ec9c commit fd2b81f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions wyoming_satellite/satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def __init__(self, settings: SatelliteSettings) -> None:

self.microphone_muted = False
self._unmute_microphone_task: Optional[asyncio.Task] = None
self._speaker_volume = self.settings.snd.volume_multiplier

# Debug audio recording
self.wake_audio_writer: Optional[DebugAudioWriter] = None
Expand Down Expand Up @@ -539,8 +540,11 @@ async def _disconnect() -> None:
await snd_client.connect()
_LOGGER.debug("Connected to snd service")

if "speaker_vol" in event.data:
self._speaker_volume = float(event.data.get("speaker_vol"))

# Audio processing
if self.settings.snd.needs_processing and AudioChunk.is_type(
if self.settings.snd.enabled and self._speaker_volume != 1.0 and AudioChunk.is_type(
event.type
):
chunk = AudioChunk.from_event(event)
Expand Down Expand Up @@ -574,9 +578,9 @@ async def _disconnect() -> None:

def _process_snd_audio(self, audio_bytes: bytes) -> bytes:
"""Perform audio pre-processing on snd output."""
if self.settings.snd.volume_multiplier != 1.0:
if self._speaker_volume != 1.0:
audio_bytes = multiply_volume(
audio_bytes, self.settings.snd.volume_multiplier
audio_bytes, self._speaker_volume
)

return audio_bytes
Expand Down

0 comments on commit fd2b81f

Please sign in to comment.