Changing the log levels used in smart_turn

This commit is contained in:
Filipi Fuchter
2025-04-17 16:14:13 -03:00
parent 3599761e4e
commit 53ee3fb64c

View File

@@ -30,16 +30,16 @@ class SmartTurnAnalyzer(BaseSmartTurn):
self.session.headers.update({"Connection": "keep-alive"}) self.session.headers.update({"Connection": "keep-alive"})
def _serialize_array(self, audio_array: np.ndarray) -> bytes: def _serialize_array(self, audio_array: np.ndarray) -> bytes:
logger.debug("Serializing NumPy array to bytes...") logger.trace("Serializing NumPy array to bytes...")
buffer = io.BytesIO() buffer = io.BytesIO()
np.save(buffer, audio_array) np.save(buffer, audio_array)
serialized_bytes = buffer.getvalue() serialized_bytes = buffer.getvalue()
logger.debug(f"Serialized size: {len(serialized_bytes)} bytes") logger.trace(f"Serialized size: {len(serialized_bytes)} bytes")
return serialized_bytes return serialized_bytes
def _send_raw_request(self, data_bytes: bytes): def _send_raw_request(self, data_bytes: bytes):
headers = {"Content-Type": "application/octet-stream"} headers = {"Content-Type": "application/octet-stream"}
logger.debug( logger.trace(
f"Sending {len(data_bytes)} bytes as raw body to {self.remote_smart_turn_url}..." f"Sending {len(data_bytes)} bytes as raw body to {self.remote_smart_turn_url}..."
) )
try: try:
@@ -50,24 +50,24 @@ class SmartTurnAnalyzer(BaseSmartTurn):
timeout=60, timeout=60,
) )
logger.debug("\n--- Response ---") logger.trace("\n--- Response ---")
logger.debug(f"Status Code: {response.status_code}") logger.trace(f"Status Code: {response.status_code}")
if response.ok: if response.ok:
try: try:
logger.debug("Response JSON:") logger.trace("Response JSON:")
logger.debug(response.json()) logger.trace(response.json())
return response.json() return response.json()
except requests.exceptions.JSONDecodeError: except requests.exceptions.JSONDecodeError:
logger.debug("Response Content (non-JSON):") logger.trace("Response Content (non-JSON):")
logger.debug(response.text) logger.trace(response.text)
else: else:
logger.debug("Response Content (Error):") logger.trace("Response Content (Error):")
logger.debug(response.text) logger.trace(response.text)
response.raise_for_status() response.raise_for_status()
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
logger.debug(f"Failed to send raw request to Daily Smart Turn: {e}") logger.error(f"Failed to send raw request to Daily Smart Turn: {e}")
raise Exception("Failed to send raw request to Daily Smart Turn.") raise Exception("Failed to send raw request to Daily Smart Turn.")
def _predict_endpoint(self, audio_array: np.ndarray) -> Dict[str, any]: def _predict_endpoint(self, audio_array: np.ndarray) -> Dict[str, any]: