mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 01:33:05 +00:00
fix: 修复豆包语音合成不能处理全字符文本的问题
This commit is contained in:
parent
4b9253f525
commit
da37338f7e
|
|
@ -12,6 +12,7 @@ import asyncio
|
|||
import copy
|
||||
import gzip
|
||||
import json
|
||||
import re
|
||||
import uuid
|
||||
from typing import Dict
|
||||
import ssl
|
||||
|
|
@ -112,6 +113,8 @@ class VolcanicEngineTextToSpeech(MaxKBBaseModel, BaseTextToSpeech):
|
|||
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 @@ class VolcanicEngineTextToSpeech(MaxKBBaseModel, BaseTextToSpeech):
|
|||
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''
|
||||
|
|
|
|||
Loading…
Reference in New Issue