diff --git a/astrbot/core/provider/sources/minimax_tts_api_source.py b/astrbot/core/provider/sources/minimax_tts_api_source.py index f40cb968ab..7ca3697088 100644 --- a/astrbot/core/provider/sources/minimax_tts_api_source.py +++ b/astrbot/core/provider/sources/minimax_tts_api_source.py @@ -65,7 +65,7 @@ def __init__( self.audio_setting: dict = { "sample_rate": 32000, "bitrate": 128000, - "format": "mp3", + "format": "wav", } self.concat_base_url: str = f"{self.api_base}?GroupId={self.group_id}" @@ -147,7 +147,7 @@ async def _audio_play(self, audio_stream: AsyncIterator[str]) -> bytes: async def get_audio(self, text: str) -> str: temp_dir = get_astrbot_temp_path() os.makedirs(temp_dir, exist_ok=True) - path = os.path.join(temp_dir, f"minimax_tts_api_{uuid.uuid4()}.mp3") + path = os.path.join(temp_dir, f"minimax_tts_api_{uuid.uuid4()}.wav") try: # 直接将异步生成器传递给 _audio_play 方法 diff --git a/astrbot/core/provider/sources/openrouter_source.py b/astrbot/core/provider/sources/openrouter_source.py index e49d0c929a..a308ad309d 100644 --- a/astrbot/core/provider/sources/openrouter_source.py +++ b/astrbot/core/provider/sources/openrouter_source.py @@ -20,3 +20,4 @@ def __init__( self.client._custom_headers["X-OpenRouter-Categories"] = ( "general-chat,personal-agent" # type: ignore ) + self.reasoning_key = "reasoning" diff --git a/astrbot/core/utils/media_utils.py b/astrbot/core/utils/media_utils.py index 40f1e60495..03d7912cb6 100644 --- a/astrbot/core/utils/media_utils.py +++ b/astrbot/core/utils/media_utils.py @@ -436,19 +436,30 @@ async def compress_image( optimize = IMAGE_COMPRESS_DEFAULT_OPTIMIZE min_file_size_bytes = int(IMAGE_COMPRESS_DEFAULT_MIN_FILE_SIZE_MB * 1024 * 1024) data = None + + def _exceeds_max_size(source: bytes | Path) -> bool: + try: + fp = io.BytesIO(source) if isinstance(source, bytes) else source + with PILImage.open(fp) as opened_img: + return max(opened_img.size) > max_size + except Exception: # noqa: BLE001 + return False + # Skip compression for remote images and return the original value. if url_or_path.startswith("http"): return url_or_path elif url_or_path.startswith("data:image"): _header, encoded = url_or_path.split(",", 1) data = base64.b64decode(encoded) - if len(data) < min_file_size_bytes: + if len(data) < min_file_size_bytes and not _exceeds_max_size(data): return url_or_path else: local_path = Path(url_or_path) if not local_path.exists(): return url_or_path - if local_path.stat().st_size < min_file_size_bytes: + if local_path.stat().st_size < min_file_size_bytes and not _exceeds_max_size( + local_path + ): return url_or_path with local_path.open("rb") as f: data = f.read()