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''