From 172e61e6be070ac35822b6ae9391e24e55e62268 Mon Sep 17 00:00:00 2001 From: Gabby Morgan Date: Tue, 6 Oct 2026 04:52:45 +0000 Subject: [PATCH] voice: add tts volume knob; louder wake cue --- config.example.json | 5 +++-- semif_agent/voice_transport.py | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/config.example.json b/config.example.json index 819a3bd..27d6049 100644 --- a/config.example.json +++ b/config.example.json @@ -173,7 +173,7 @@ "enabled": true, "frequency": 880, "duration_ms": 120, - "volume": 0.25, + "volume": 0.9, "submit_frequency": 0, "submit_duration_ms": 100 }, @@ -193,7 +193,8 @@ "voice": "en_US-lessac-medium", "voice_dir": "", "speaker_id": 0, - "length_scale": 1.0 + "length_scale": 1.0, + "volume": 1.0 }, "audio": { "input_device": "", diff --git a/semif_agent/voice_transport.py b/semif_agent/voice_transport.py index b418674..34969c0 100644 --- a/semif_agent/voice_transport.py +++ b/semif_agent/voice_transport.py @@ -249,11 +249,12 @@ class WhisperTranscriber(Transcriber): class PiperSynthesizer(Synthesizer): """Piper TTS. `voice` is a voice name (resolved to a `.onnx`) or a path.""" - def __init__(self, voice: str, speaker_id: int = 0, length_scale: float = 1.0): + def __init__(self, voice: str, speaker_id: int = 0, length_scale: float = 1.0, + volume: float = 1.0): from piper import PiperVoice self._voice = PiperVoice.load(str(voice)) - self._syn_config = _piper_syn_config(speaker_id, length_scale) + self._syn_config = _piper_syn_config(speaker_id, length_scale, volume) def synthesize(self, text: str) -> tuple[bytes, int]: buffer = io.BytesIO() @@ -273,7 +274,7 @@ class PiperSynthesizer(Synthesizer): return wav_file.readframes(wav_file.getnframes()), wav_file.getframerate() -def _piper_syn_config(speaker_id: int, length_scale: float): +def _piper_syn_config(speaker_id: int, length_scale: float, volume: float = 1.0): """A piper `SynthesisConfig` when the installed version provides one.""" try: from piper import SynthesisConfig @@ -284,6 +285,8 @@ def _piper_syn_config(speaker_id: int, length_scale: float): kwargs["speaker_id"] = int(speaker_id) if length_scale and float(length_scale) != 1.0: kwargs["length_scale"] = float(length_scale) + if volume and float(volume) != 1.0: + kwargs["volume"] = float(volume) if not kwargs: return None try: @@ -551,6 +554,7 @@ def build_engines(cfg: dict, trace=None) -> VoiceEngines: tts_voice, speaker_id=int(tts_cfg.get("speaker_id", 0) or 0), length_scale=float(tts_cfg.get("length_scale", 1.0) or 1.0), + volume=float(tts_cfg.get("volume", 1.0) or 1.0), ), audio=SoundDeviceAudio( input_device=str(audio_cfg.get("input_device", "") or ""),