From da37338f7eaba83de0c275c5cda15a47fa5400cd Mon Sep 17 00:00:00 2001 From: CaptainB Date: Mon, 28 Oct 2024 11:32:01 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B1=86=E5=8C=85?= =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E5=90=88=E6=88=90=E4=B8=8D=E8=83=BD=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=85=A8=E5=AD=97=E7=AC=A6=E6=96=87=E6=9C=AC=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/volcanic_engine_model_provider/model/tts.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/setting/models_provider/impl/volcanic_engine_model_provider/model/tts.py b/apps/setting/models_provider/impl/volcanic_engine_model_provider/model/tts.py index e2cc4e2867..ec39f22c04 100644 --- a/apps/setting/models_provider/impl/volcanic_engine_model_provider/model/tts.py +++ b/apps/setting/models_provider/impl/volcanic_engine_model_provider/model/tts.py @@ -12,6 +12,7 @@ import copy import gzip import json +import re import uuid from typing import Dict import ssl @@ -112,6 +113,8 @@ async def submit(self, request_json, text): ssl=ssl_context) as ws: lines = text.split('\n') for line in lines: + if self.is_table_format_chars_only(line): + continue submit_request_json["request"]["reqid"] = str(uuid.uuid4()) submit_request_json["request"]["text"] = line payload_bytes = str.encode(json.dumps(submit_request_json)) @@ -123,6 +126,11 @@ async def submit(self, request_json, text): result += await self.parse_response(ws) return result + @staticmethod + def is_table_format_chars_only(s): + # 检查是否仅包含 "|", "-", 和空格字符 + return bool(s) and re.fullmatch(r'[|\-\s]+', s) + @staticmethod async def parse_response(ws): result = b''