voice: add tts volume knob; louder wake cue

This commit is contained in:
gabby committed 2026-10-06 04:52:45 +00:00
1 parent d2f9a74bd9
commit 172e61e6be
2 files changed
+10 -5

No files matched your search

+3 -2
View File
@@ -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": "",
+7 -3
View File
@@ -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 ""),