Skip to content

Commit da37338

Browse files
committed
fix: 修复豆包语音合成不能处理全字符文本的问题
1 parent 4b9253f commit da37338

File tree

1 file changed

+8
-0
lines changed
  • apps/setting/models_provider/impl/volcanic_engine_model_provider/model

1 file changed

+8
-0
lines changed

apps/setting/models_provider/impl/volcanic_engine_model_provider/model/tts.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import copy
1313
import gzip
1414
import json
15+
import re
1516
import uuid
1617
from typing import Dict
1718
import ssl
@@ -112,6 +113,8 @@ async def submit(self, request_json, text):
112113
ssl=ssl_context) as ws:
113114
lines = text.split('\n')
114115
for line in lines:
116+
if self.is_table_format_chars_only(line):
117+
continue
115118
submit_request_json["request"]["reqid"] = str(uuid.uuid4())
116119
submit_request_json["request"]["text"] = line
117120
payload_bytes = str.encode(json.dumps(submit_request_json))
@@ -123,6 +126,11 @@ async def submit(self, request_json, text):
123126
result += await self.parse_response(ws)
124127
return result
125128

129+
@staticmethod
130+
def is_table_format_chars_only(s):
131+
# 检查是否仅包含 "|", "-", 和空格字符
132+
return bool(s) and re.fullmatch(r'[|\-\s]+', s)
133+
126134
@staticmethod
127135
async def parse_response(ws):
128136
result = b''

0 commit comments

Comments
 (0)