fix: clean junk text from Antaf + use int8 TTS model for speed
- Filter "完成资料引用" and other status text from Antaf responses - Use int8 quantized model for faster TTS inference - Add configurable num_threads for sherpa-onnx Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e5599d4f43
commit
c2727d7e08
|
|
@ -37,6 +37,17 @@ class LLMProvider(LLMProviderBase):
|
|||
return True
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _clean_text(text):
|
||||
"""清理阿福返回文本中的脏数据"""
|
||||
# 去掉阿福内部状态文本
|
||||
junk = [
|
||||
"完成资料引用", "内容生成", "正在思考", "正在搜索",
|
||||
]
|
||||
for j in junk:
|
||||
text = text.replace(j, "")
|
||||
return text.strip()
|
||||
|
||||
@staticmethod
|
||||
def _is_system_injected(content):
|
||||
"""检测是否为系统注入的消息(非用户真实输入)"""
|
||||
|
|
@ -108,6 +119,10 @@ class LLMProvider(LLMProviderBase):
|
|||
if self._is_thinking(data):
|
||||
logger.bind(tag=TAG).debug(f"过滤思考内容: {data[:50]}...")
|
||||
continue
|
||||
# 清理脏数据
|
||||
data = self._clean_text(data)
|
||||
if not data:
|
||||
continue
|
||||
yield data
|
||||
|
||||
except requests.exceptions.ConnectionError:
|
||||
|
|
|
|||
|
|
@ -17,14 +17,23 @@ class TTSProvider(TTSProviderBase):
|
|||
self.speed = float(speed) if speed else 1.0
|
||||
self.sid = int(config.get("sid", 0))
|
||||
|
||||
# 优先使用 int8 量化模型(更快)
|
||||
model_file = f"{model_dir}/model.int8.onnx"
|
||||
import os
|
||||
if not os.path.exists(model_file):
|
||||
model_file = f"{model_dir}/model.onnx"
|
||||
|
||||
num_threads = int(config.get("num_threads", 4))
|
||||
|
||||
tts_config = sherpa_onnx.OfflineTtsConfig(
|
||||
model=sherpa_onnx.OfflineTtsModelConfig(
|
||||
vits=sherpa_onnx.OfflineTtsVitsModelConfig(
|
||||
model=f"{model_dir}/model.onnx",
|
||||
model=model_file,
|
||||
lexicon=f"{model_dir}/lexicon.txt",
|
||||
tokens=f"{model_dir}/tokens.txt",
|
||||
dict_dir=f"{model_dir}/dict",
|
||||
),
|
||||
num_threads=num_threads,
|
||||
),
|
||||
rule_fsts=f"{model_dir}/date.fst,{model_dir}/phone.fst,{model_dir}/number.fst,{model_dir}/new_heteronym.fst",
|
||||
max_num_sentences=1,
|
||||
|
|
|
|||
Loading…
Reference in New Issue