Compare commits

..

2 Commits

Author SHA1 Message Date
zhaojie
584543395c fix: 更新 TTS 模型名 mimo-v2-audio-tts -> mimo-v2-tts
小米 MiMo-V2-TTS 于 2026-03-19 正式发布后,旧模型名 mimo-v2-audio-tts
已不再被 API 支持,导致所有 TTS 请求返回 400 错误。
2026-04-01 14:38:32 +08:00
sunruiling
fb753ce1b1 chore: 优化日志,静默 httpx 内部日志,精简输出格式 2026-03-27 15:24:25 +08:00
5 changed files with 13 additions and 11 deletions

View File

@@ -6,5 +6,5 @@ MIMO_API_KEY=your_api_key_here
# 以下为可选配置(有默认值)
# MIMO_API_ENDPOINT=https://api.xiaomimimo.com/v1/chat/completions
# MIMO_TTS_MODEL=mimo-v2-audio-tts
# MIMO_TTS_MODEL=mimo-v2-tts
# MIMO_VOICE=mimo_default

View File

@@ -74,7 +74,7 @@ App 模板变量:`{{speakText}}`(文本)、`{{speakSpeed}}`(语速 5-50
|------|------|--------|------|
| `MIMO_API_KEY` | ✅ | - | MiMo TTS API Key |
| `MIMO_API_ENDPOINT` | ❌ | `https://api.xiaomimimo.com/v1/chat/completions` | API 地址 |
| `MIMO_TTS_MODEL` | ❌ | `mimo-v2-audio-tts` | 模型名称 |
| `MIMO_TTS_MODEL` | ❌ | `mimo-v2-tts` | 模型名称 |
| `MIMO_VOICE` | ❌ | `mimo_default` | 默认音色 |
| `API_TOKEN` | ❌ | - | 管理接口 Bearer Token留空则不鉴权 |

View File

@@ -7,7 +7,7 @@ MIMO_API_ENDPOINT = os.environ.get(
"MIMO_API_ENDPOINT", "https://api.xiaomimimo.com/v1/chat/completions"
)
MIMO_API_KEY = os.environ.get("MIMO_API_KEY", "")
MIMO_TTS_MODEL = os.environ.get("MIMO_TTS_MODEL", "mimo-v2-audio-tts")
MIMO_TTS_MODEL = os.environ.get("MIMO_TTS_MODEL", "mimo-v2-tts")
MIMO_VOICE = os.environ.get("MIMO_VOICE", "mimo_default")
# 服务器配置

View File

@@ -25,10 +25,12 @@ import config
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(levelname)s] %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
format="%(asctime)s %(message)s",
datefmt="%H:%M:%S",
)
logger = logging.getLogger("tts-proxy")
logger = logging.getLogger("tts")
# 静默 httpx 内部日志
logging.getLogger("httpx").setLevel(logging.WARNING)
# ── Text Segmentation ─────────────────────────────────────────────────────
@@ -152,7 +154,7 @@ async def call_mimo_tts(text: str, style: str = "", voice: str = "") -> bytes:
elapsed = round(time.time() - t0, 2)
if resp.status_code != 200:
logger.error(f"MiMo TTS HTTP {resp.status_code}, {elapsed}s, {resp.text[:200]}")
logger.error(f"TTS FAIL http={resp.status_code} {elapsed}s")
err = HTTPException(502, f"MiMo TTS API 错误: HTTP {resp.status_code}")
if resp.status_code >= 500 and attempt < MAX_TTS_RETRIES:
last_exc = err
@@ -166,14 +168,14 @@ async def call_mimo_tts(text: str, style: str = "", voice: str = "") -> bytes:
audio_b64 = data["choices"][0]["message"]["audio"]["data"]
wav_bytes = base64.b64decode(audio_b64)
logger.info(f"MiMo TTS OK: {len(wav_bytes)} bytes, {elapsed}s (attempt {attempt})")
logger.info(f"TTS OK {len(wav_bytes)//1024}KB {elapsed}s")
return wav_bytes
except HTTPException:
raise
except Exception as e:
elapsed = round(time.time() - t0, 2)
logger.error(f"MiMo TTS 异常: {e}, {elapsed}s, attempt {attempt}")
logger.error(f"TTS ERR {e} {elapsed}s")
last_exc = HTTPException(502, f"MiMo TTS 异常: {e}")
if attempt < MAX_TTS_RETRIES:
await asyncio.sleep(1.5 * attempt)
@@ -205,7 +207,7 @@ async def generate_mp3(text: str, style: str = "", voice: str = "") -> bytes:
return mp3_bytes
# 多段
logger.info(f"文本 {len(text)} 字, 分 {len(chunks)} 段生成")
logger.info(f"SPLIT {len(text)}字 → {len(chunks)}")
mp3_paths = []
for chunk in chunks:
wav_bytes = await call_mimo_tts(chunk, style, voice)

View File

@@ -9,7 +9,7 @@ services:
environment:
- MIMO_API_KEY=${MIMO_API_KEY}
- MIMO_API_ENDPOINT=${MIMO_API_ENDPOINT:-https://api.xiaomimimo.com/v1/chat/completions}
- MIMO_TTS_MODEL=${MIMO_TTS_MODEL:-mimo-v2-audio-tts}
- MIMO_TTS_MODEL=${MIMO_TTS_MODEL:-mimo-v2-tts}
- MIMO_VOICE=${MIMO_VOICE:-mimo_default}
- API_TOKEN=${API_TOKEN:-}
volumes: