From 6dc388a7945181caeeaebed4292f9d718ffd9136 Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Wed, 29 Jul 2026 14:40:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(cosyvoice):=20=E4=BF=AE=E5=A4=8Dprefix?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E4=B8=AD=E6=96=87=E5=A4=B1=E6=95=88=E5=AF=BC?= =?UTF-8?q?=E8=87=B4400=E9=94=99=E8=AF=AF=20(#1138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复prefix过滤中文失效导致400错误 --- packages/application/cosyvoice_service.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/application/cosyvoice_service.py b/packages/application/cosyvoice_service.py index f797e3f5b..6b645f91c 100755 --- a/packages/application/cosyvoice_service.py +++ b/packages/application/cosyvoice_service.py @@ -569,7 +569,9 @@ class CosyVoiceService: 清洗后的 prefix """ # 只保留字母和数字 - cleaned = "".join(c for c in name if c.isalnum()) + import re + + cleaned = re.sub(r"[^a-zA-Z0-9]", "", name) # 最多10字符 cleaned = cleaned[:10] # 如果清洗后为空,用默认值