The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(tools): fold sniff/read into one with-block, lifecycle timing locals
Teknium01262a79eb36
diff --git a/tools/tts_tool_delivery.py b/tools/tts_tool_delivery.pyindex 44ac43c5e7d..bae7da2bf04 100644--- a/tools/tts_tool_delivery.py+++ b/tools/tts_tool_delivery.py@@ -335,10 +335,9 @@ def _sniff_audio_container(path: str) -> str:from tools.audio_container import sniff_containertry:with open(path, "rb") as fh:- head = fh.read(12)+ return sniff_container(fh.read(12)) or "unknown"except OSError:return "unknown"- return sniff_container(head) or "unknown"def _repair_ogg_container(file_str: str) -> str:@@ -351,7 +350,7 @@ def _repair_ogg_container(file_str: str) -> str:repaired = _ffmpeg_transcode_to_opus(file_str, file_str)if repaired:return repaired- honest = file_str[:-4] + "." + container+ honest = f"{file_str[:-4]}.{container}"try:os.replace(file_str, honest)except OSError:diff --git a/tools/tts_tool_lifecycle.py b/tools/tts_tool_lifecycle.pyindex 37b7ecb7663..4df1f1bb6a5 100644--- a/tools/tts_tool_lifecycle.py+++ b/tools/tts_tool_lifecycle.py@@ -89,8 +89,7 @@ def warm_tts_provider(tts_config: Optional[Dict[str, Any]] = None, provider: Optwarmer = _local_tts_warmers().get(name)if warmer is not None:cache = _LOCAL_TTS_MODEL_CACHES.get(name, {})- before = len(cache)- started = time.monotonic()+ before, started = len(cache), time.monotonic()try:warmer(tts_config)except Exception as exc: # engine missing, download failed, bad voice…diff --git a/tools/tts_tool_speaker.py b/tools/tts_tool_speaker.pyindex bb764d7e8c2..f095b46aecb 100644--- a/tools/tts_tool_speaker.py+++ b/tools/tts_tool_speaker.py@@ -183,8 +183,8 @@ class _StreamerPlayback:self._prefetch_sem.acquire()chunk_queue: "queue.Queue[Optional[bytes]]" = queue.Queue(maxsize=self._CHUNK_QUEUE_MAX)self._audio_queue.put(chunk_queue)- self._prefetch_threads.append(- threading.Thread(target=self._consume_to_queue, args=(audio_iter, chunk_queue), daemon=True))+ self._prefetch_threads.append(threading.Thread(+ target=self._consume_to_queue, args=(audio_iter, chunk_queue), daemon=True))self._prefetch_threads[-1].start()def _consume_to_queue(self, audio_iter: Iterator[bytes], chunk_queue: "queue.Queue[Optional[bytes]]") -> None: