Add sound volume multiplier

This commit is contained in:
Michael Hansen
2024-01-16 17:06:30 -06:00
parent a44dc28cdf
commit f6fcf74c3a
4 changed files with 40 additions and 12 deletions
+13 -4
View File
@@ -35,7 +35,12 @@ def configure_microphone(settings: Settings) -> None:
_LOGGER.warning("Failed to record from microphone %s", device)
continue
_LOGGER.debug("Microphone %s got RMS %s (min: %s)", device, device_rms, RECORD_RMS_MIN)
_LOGGER.debug(
"Microphone %s got RMS %s (min: %s)",
device,
device_rms,
RECORD_RMS_MIN,
)
if device_rms < RECORD_RMS_MIN:
continue
@@ -48,8 +53,10 @@ def configure_microphone(settings: Settings) -> None:
settings.mic.device = best_device
settings.save()
else:
msgbox("Audio was not detected from any microphone.\n"
"If a satellite is currently running, you may need to stop it.")
msgbox(
"Audio was not detected from any microphone.\n"
"If a satellite is currently running, you may need to stop it."
)
elif choice == "list":
# arecord -L
microphone_device = radiolist(
@@ -120,7 +127,9 @@ def _record_proc(device: str) -> Optional[float]:
)
audio, stderr = proc.communicate()
if proc.returncode != 0:
_LOGGER.error("Error recording from device %s: %s", device, stderr.decode("utf-8"))
_LOGGER.error(
"Error recording from device %s: %s", device, stderr.decode("utf-8")
)
return None
# 16-bit mono
+4 -6
View File
@@ -17,7 +17,7 @@ from .whiptail import error, msgbox, run_with_gauge
def stop_services(password: str) -> None:
stop_commands = []
for service in ("satellite", "openwakeword", "porcupine1", "snowboy"):
for service in ("satellite", "wakeword", "event"):
service_filename = f"wyoming-{service}.service"
service_path = Path("/etc/systemd/system") / service_filename
if not service_path.exists():
@@ -83,10 +83,8 @@ def generate_services(settings: Settings) -> None:
# Local wake word detection
assert settings.wake.system is not None, "Wake word system not set"
wake_word_service = (
"wyoming-" + WakeWordSystem(settings.wake.system).value.lower()
)
wake_word_dir = LOCAL_DIR / wake_word_service
wake_word_service = "wyoming-wakeword"
wake_word_dir = LOCAL_DIR / WakeWordSystem(settings.wake.system).value.lower()
wake_word_command = [
str(wake_word_dir / "script" / "run"),
"--uri",
@@ -165,7 +163,7 @@ def generate_services(settings: Settings) -> None:
SERVICES_DIR / f"{event_service}.service", "w", encoding="utf-8"
) as service_file:
print("[Unit]", file=service_file)
print(f"Description=Event service", file=service_file)
print("Description=Event service", file=service_file)
print("", file=service_file)
print("[Service]", file=service_file)
print("Type=simple", file=service_file)
+21
View File
@@ -53,6 +53,26 @@ def configure_speakers(settings: Settings) -> None:
if feedback_sounds is not None:
settings.snd.feedback_sounds = feedback_sounds
settings.save()
elif choice == "multiplier":
while True:
volume_multiplier = inputbox(
"Volume Multipler (1 = default)", settings.snd.volume_multiplier
)
if volume_multiplier is None:
break
try:
volume_multiplier_float = float(volume_multiplier)
except ValueError:
msgbox("Invalid value")
continue
if volume_multiplier_float > 0:
settings.snd.volume_multiplier = volume_multiplier_float
settings.save()
break
msgbox("Must be > 0")
else:
break
@@ -66,6 +86,7 @@ def speakers_menu(last_choice: Optional[str]) -> Optional[str]:
("list", "Select From List"),
("manual", "Enter Manually"),
("disable", "Disable Sound"),
("multipler", "Volume Multipler"),
("feedback", "Toggle Feedback Sounds"),
],
selected_item=last_choice,