Commit ·
9844c98
1
Parent(s): 8d667cb
fix: Add debug logging for noise suppression, fix PP_MIN_NN value
Browse files
reachy_mini_ha_voice/reachy_controller.py
CHANGED
|
@@ -769,16 +769,25 @@ class ReachyController:
|
|
| 769 |
logger.error(f"Error setting AGC max gain: {e}")
|
| 770 |
|
| 771 |
def get_noise_suppression(self) -> float:
|
| 772 |
-
"""Get noise suppression level (0-100%).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 773 |
with self._get_respeaker() as respeaker:
|
| 774 |
if respeaker is None:
|
| 775 |
return getattr(self, '_noise_suppression', 15.0)
|
| 776 |
try:
|
| 777 |
result = respeaker.read("PP_MIN_NS")
|
| 778 |
if result is not None:
|
| 779 |
-
|
| 780 |
-
#
|
| 781 |
-
self._noise_suppression = max(0.0, min(100.0, (1.0 -
|
|
|
|
| 782 |
return self._noise_suppression
|
| 783 |
except Exception as e:
|
| 784 |
logger.debug(f"Error getting noise suppression: {e}")
|
|
|
|
| 769 |
logger.error(f"Error setting AGC max gain: {e}")
|
| 770 |
|
| 771 |
def get_noise_suppression(self) -> float:
|
| 772 |
+
"""Get noise suppression level (0-100%).
|
| 773 |
+
|
| 774 |
+
PP_MIN_NS represents "minimum signal preservation ratio":
|
| 775 |
+
- PP_MIN_NS = 0.85 means "keep at least 85% of signal" = 15% suppression
|
| 776 |
+
- PP_MIN_NS = 0.15 means "keep at least 15% of signal" = 85% suppression
|
| 777 |
+
|
| 778 |
+
We display "noise suppression strength" to user, so:
|
| 779 |
+
- suppression_percent = (1.0 - PP_MIN_NS) * 100
|
| 780 |
+
"""
|
| 781 |
with self._get_respeaker() as respeaker:
|
| 782 |
if respeaker is None:
|
| 783 |
return getattr(self, '_noise_suppression', 15.0)
|
| 784 |
try:
|
| 785 |
result = respeaker.read("PP_MIN_NS")
|
| 786 |
if result is not None:
|
| 787 |
+
raw_value = result[0]
|
| 788 |
+
# Convert: PP_MIN_NS=0.85 -> 15% suppression, PP_MIN_NS=0.15 -> 85% suppression
|
| 789 |
+
self._noise_suppression = max(0.0, min(100.0, (1.0 - raw_value) * 100.0))
|
| 790 |
+
logger.debug(f"Noise suppression: PP_MIN_NS={raw_value:.2f} -> {self._noise_suppression:.1f}%")
|
| 791 |
return self._noise_suppression
|
| 792 |
except Exception as e:
|
| 793 |
logger.debug(f"Error getting noise suppression: {e}")
|
reachy_mini_ha_voice/voice_assistant.py
CHANGED
|
@@ -307,19 +307,20 @@ class VoiceAssistantService:
|
|
| 307 |
# ========== 3. Noise Suppression Settings ==========
|
| 308 |
# Reduce noise suppression to preserve quiet speech
|
| 309 |
# PP_MIN_NS: minimum noise suppression threshold
|
| 310 |
-
#
|
| 311 |
-
#
|
|
|
|
| 312 |
try:
|
| 313 |
-
respeaker.write("PP_MIN_NS", [0.85]) # 15% noise suppression
|
| 314 |
-
_LOGGER.info("Noise suppression set to 15%% (PP_MIN_NS=0.85)")
|
| 315 |
except Exception as e:
|
| 316 |
_LOGGER.debug("Could not set PP_MIN_NS: %s", e)
|
| 317 |
|
| 318 |
# PP_MIN_NN: minimum noise floor estimation
|
| 319 |
-
#
|
| 320 |
try:
|
| 321 |
-
respeaker.write("PP_MIN_NN", [0.
|
| 322 |
-
_LOGGER.info("Noise floor threshold
|
| 323 |
except Exception as e:
|
| 324 |
_LOGGER.debug("Could not set PP_MIN_NN: %s", e)
|
| 325 |
|
|
|
|
| 307 |
# ========== 3. Noise Suppression Settings ==========
|
| 308 |
# Reduce noise suppression to preserve quiet speech
|
| 309 |
# PP_MIN_NS: minimum noise suppression threshold
|
| 310 |
+
# Higher values = less aggressive suppression = better voice pickup
|
| 311 |
+
# PP_MIN_NS = 0.85 means "keep at least 85% of signal" = 15% max suppression
|
| 312 |
+
# UI shows "noise suppression strength" so 15% = PP_MIN_NS of 0.85
|
| 313 |
try:
|
| 314 |
+
respeaker.write("PP_MIN_NS", [0.85]) # 15% noise suppression strength
|
| 315 |
+
_LOGGER.info("Noise suppression set to 15%% strength (PP_MIN_NS=0.85)")
|
| 316 |
except Exception as e:
|
| 317 |
_LOGGER.debug("Could not set PP_MIN_NS: %s", e)
|
| 318 |
|
| 319 |
# PP_MIN_NN: minimum noise floor estimation
|
| 320 |
+
# Higher values = less aggressive noise floor tracking
|
| 321 |
try:
|
| 322 |
+
respeaker.write("PP_MIN_NN", [0.85]) # Match PP_MIN_NS
|
| 323 |
+
_LOGGER.info("Noise floor threshold set (PP_MIN_NN=0.85)")
|
| 324 |
except Exception as e:
|
| 325 |
_LOGGER.debug("Could not set PP_MIN_NN: %s", e)
|
| 326 |
|