Skip to content

Commit

Permalink
fix/ducking
Browse files Browse the repository at this point in the history
- BUG - missed a reference to removed self.tts object
- refactor config options to expose
  - pulse_duck -> let pa handle ducking
  - ocp_cork -> new ovos-media event to pause/unpause audio
  - ocp_duck -> ovos-media event to lower volume
  • Loading branch information
JarbasAl committed Apr 29, 2024
1 parent 854c8f7 commit 6fffcf1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions ovos_audio/playback.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import random
from ovos_audio.transformers import TTSTransformersService
from ovos_bus_client.message import Message
from ovos_config import Configuration
from ovos_plugin_manager.templates.tts import TTS
from ovos_utils.log import LOG, log_deprecation
from ovos_utils.sound import play_audio
Expand Down Expand Up @@ -55,8 +56,12 @@ def clear_queue(self):
def begin_audio(self, message=None):
"""Perform beginning of speech actions."""
if self.bus:
if not self.tts.config.get("pulse_duck", False):
self.bus.emit(Message("ovos.common_play.duck"))
cfg = Configuration().get("tts", {})
if not cfg.get("pulse_duck"): # OS is configured to use pulseaudio modules directly
if cfg.get("ocp_cork", False):
self.bus.emit(Message("ovos.common_play.cork"))
elif cfg.get("ocp_duck", False):
self.bus.emit(Message("ovos.common_play.duck"))
message = message or Message("speak")
self.bus.emit(message.forward("recognizer_loop:audio_output_start"))
else:
Expand All @@ -70,8 +75,12 @@ def end_audio(self, listen, message=None):
listen (bool): True if listening event should be emitted
"""
if self.bus:
if not self.tts.config.get("pulse_duck", False):
self.bus.emit(Message("ovos.common_play.unduck"))
cfg = Configuration().get("tts", {})
if not cfg.get("pulse_duck"): # OS is configured to use pulseaudio modules directly
if cfg.get("ocp_cork", False):
self.bus.emit(Message("ovos.common_play.uncork"))
elif cfg.get("ocp_duck", False):
self.bus.emit(Message("ovos.common_play.unduck"))
# Send end of speech signals to the system
message = message or Message("speak")
self.bus.emit(message.forward("recognizer_loop:audio_output_end"))
Expand Down

0 comments on commit 6fffcf1

Please sign in to comment.