AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug] 文本转图像在 TTS 同时输出文本时失效

Open pjh456 opened this issue 6 months ago • 1 comments

What happened / 发生了什么

在启用 TTS,开启 TTS 时同时输出语音和文字内容后,文本转图像功能失效,无法在达到阈值后转为图片。

Reproduce / 如何复现?

  1. 开启 TTS 供应商并确保可用
  2. 在普通配置中开启“文本转图像输出”、“启用文本转语音”和“开启 TTS 时同时输出语音和文字内容”
  3. 为文本转图像设置一个较小的阈值(或默认的150)
  4. 与模型对话,发现在字数超过阈值时也无法触发文本转图像

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

4.24.4 Astrbot,Linux Docker Compose 部署,使用 newapi 第三方中转站供应商(OpenAI 兼容接口),aiocqhttp / OneBot v11 (对接 NapCat) 消息平台适配器

OS

Linux

Logs / 报错日志

日志已做脱敏处理:

[2026-05-20 16:55:20.815] [Core]
[INFO]
[core.event_bus:61]: [murasame_skill] [murasame(aiocqhttp)] ☞♛☜/xxx: 按这个规律,总数改到160个 
[2026-05-20 16:55:20.815] [Core] [DBUG] [waking_check.stage:158]: enabled_plugins_name: ['astrbot_plugin_minecraftconsole', 'astrbot_plugin_AtTool', 'astrbot_plugin_fortnue', 'astrbot_plugin_chuanhuatong', 'vv_pic', 'astrbot_plugin_command_query', 'zhiyu-astrbot-hjm', 'astrbot_plugin_github_analyzer', 'astrbot_plugin_echo', 'astrbot_plugin_reneban', 'astrbot_plugin_livingmemory', 'astrbot_plugin_uapipro_toolbox', 'astrbot_plugin_llm_executor', 'astrbot_plugin_proactive_chat', 'astrbot_plugin_auto_approve_all', 'group_sign', 'qq_group_sign', 'astrbot_plugin_qzone_tools', 'astrbot_plugin_lili_state', 'favorpro', 'astrbot_plugin_pic_mirror']
[2026-05-20 16:55:20.819] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot - handle_session_control_agent
[2026-05-20 16:55:20.819] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot - handle_empty_mention
[2026-05-20 16:55:20.819] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_proactive_chat - on_friend_message
[2026-05-20 16:55:20.819] [Plug] [DBUG] [core.message_events:75]: [主动消息] 私聊 xxx 未启用或配置无效,跳过处理喵。
[2026-05-20 16:55:20.819] [Core] [DBUG] [method.star_request:46]: plugin -> qq_group_sign - _capture_bot_instance
[2026-05-20 16:55:20.820] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_reneban - filter_banned_users
[2026-05-20 16:55:20.822] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_auto_approve_all - event_monitoring
[2026-05-20 16:55:20.823] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot - on_message
[2026-05-20 16:55:20.823] [Core] [DBUG] [method.star_request:46]: plugin -> astrbot_plugin_pic_mirror - handle_all_mirror_commands
[2026-05-20 16:55:20.825] [Core] [DBUG] [agent_sub_stages.internal:181]: ready to request llm provider
[2026-05-20 16:55:20.825] [Core] [DBUG] [agent_sub_stages.internal:204]: acquired session lock for llm request
[2026-05-20 16:55:20.834] [Core] [DBUG] [tools.knowledge_base_tools:61]: [知识库] 使用全局配置,知识库数量: 0
[2026-05-20 16:55:20.835] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMRequestEvent) -> astrbot_plugin_qzone_tools - on_llm_request
[2026-05-20 16:55:20.835] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMRequestEvent) -> astrbot_plugin_AtTool - inject_at_instruction
[2026-05-20 16:55:20.835] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMRequestEvent) -> astrbot - decorate_llm_req
[2026-05-20 16:55:21.332] [Core] [DBUG] [runners.base:64]: Agent state transition: AgentState.IDLE -> AgentState.RUNNING
[2026-05-20 16:55:21.333] [Core] [DBUG] [runners.tool_loop_agent_runner:613]: [BefCompact] RunCtx.messages -> [33] system,user,assistant,tool,assistant,tool,assistant,user,assistant,tool,assistant,tool,tool,tool,assistant,user,assistant,tool,tool,assistant,user,assistant,tool,assistant,tool,assistant,user,assistant,user,assistant,user,assistant,user
[2026-05-20 16:55:21.333] [Core] [DBUG] [runners.tool_loop_agent_runner:613]: [AftCompact] RunCtx.messages -> [33] system,user,assistant,tool,assistant,tool,assistant,user,assistant,tool,assistant,tool,tool,tool,assistant,user,assistant,tool,tool,assistant,user,assistant,tool,assistant,tool,assistant,user,assistant,user,assistant,user,assistant,user
[2026-05-20 16:55:25.230] [Core] [DBUG] [sources.openai_source:607]: completion: ChatCompletion(id='resp_0809d6772f1ea8ec016a0d76fa96688193bd9148f3ba4528d0', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content='1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890', refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None))], created=1779267325, model='gpt-5.5', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=92, prompt_tokens=19865, total_tokens=19957, completion_tokens_details=None, prompt_tokens_details=PromptTokensDetails(audio_tokens=None, cached_tokens=19456)))
[2026-05-20 16:55:25.230] [Core] [DBUG] [runners.base:64]: Agent state transition: AgentState.RUNNING -> AgentState.DONE
[2026-05-20 16:55:25.231] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMResponseEvent) -> astrbot_plugin_qzone_tools - on_llm_response
[2026-05-20 16:55:25.231] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnLLMResponseEvent) -> astrbot - record_llm_resp_to_ltm
[2026-05-20 16:55:25.231] [Core] [DBUG] [result_decorate.stage:165]: hook(on_decorating_result) -> astrbot_plugin_AtTool - process_at_tags
[2026-05-20 16:55:25.237] [Core]
[INFO]
[result_decorate.stage:301]: TTS 请求: 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
[2026-05-20 16:55:25.237] [Core] [DBUG] [sources.gsv_selfhosted_source:128]: [GSV TTS] 正在调用语音合成接口,参数:{'ref_audio_path': '/home/123/default_audio/ふむ、お主が我輩のご主人か.ogg', 'prompt_text': 'ふむ、お主が我輩のご主人か', 'prompt_lang': 'ja', 'aux_ref_audio_paths': '', 'text_lang': 'auto', 'top_k': '15', 'top_p': '1', 'temperature': '1', 'text_split_method': 'cut3', 'batch_size': '4', 'batch_threshold': '0.75', 'split_bucket': 'true', 'speed_factor': '1', 'fragment_interval': '0.3', 'streaming_mode': 'false', 'seed': '-1', 'parallel_infer': 'true', 'repetition_penalty': '1.35', 'media_type': 'wav', 'text': '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'}
[2026-05-20 16:55:25.237] [Core] [DBUG] [sources.gsv_selfhosted_source:69]: [GSV TTS] 请求地址:http://127.0.0.1:9880/tts,参数:{'ref_audio_path': '/home/123/default_audio/ふむ、お主が我輩のご主人か.ogg', 'prompt_text': 'ふむ、お主が我輩のご主人か', 'prompt_lang': 'ja', 'aux_ref_audio_paths': '', 'text_lang': 'auto', 'top_k': '15', 'top_p': '1', 'temperature': '1', 'text_split_method': 'cut3', 'batch_size': '4', 'batch_threshold': '0.75', 'split_bucket': 'true', 'speed_factor': '1', 'fragment_interval': '0.3', 'streaming_mode': 'false', 'seed': '-1', 'parallel_infer': 'true', 'repetition_penalty': '1.35', 'media_type': 'wav', 'text': '1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890'}
[2026-05-20 16:55:41.385] [Core]
[INFO]
[result_decorate.stage:303]: TTS 结果: /AstrBot/data/temp/gsv_tts_8ca74a9a74e74a28b7010bd07f759070.wav
[2026-05-20 16:55:41.385] [Core]
[INFO]
[respond.stage:183]: Prepare to send - ☞♛☜/xxx: [ComponentType.Record] 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890 
[2026-05-20 16:55:43.494] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnAfterMessageSentEvent) -> astrbot_plugin_proactive_chat - on_after_message_sent
[2026-05-20 16:55:43.494] [Core] [DBUG] [pipeline.context_utils:95]: hook(OnAfterMessageSentEvent) -> astrbot - after_message_sent
[2026-05-20 16:55:43.505] [Core] [DBUG] [pipeline.scheduler:93]: pipeline 执行完毕。

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • [ ] Yes!

Code of Conduct

pjh456 avatar May 20 '26 09:05 pjh456

这个 bug 的根本原因已经定位到了。问题出在 astrbot/core/pipeline/result_decorate/stage.py 中 TTS 和文本转图像(T2I)的处理顺序和逻辑冲突:

原因分析:

  1. TTS 在 T2I 之前执行(TTS: ~第255-344行,T2I: ~第346-385行)[1]
  2. 当 TTS 开启 dual_output(同时输出语音和文字)时,会将消息链重构为 [Record, Plain, Record, Plain, ...] 的交替结构 [2]
  3. T2I 的文本聚合逻辑从链头开始遍历,遇到第一个非 Plain 组件就立即 break [3]
  4. 由于 TTS dual_output 将 Record 放在了 Plain 前面,T2I 遍历时第一个就碰到 Record,直接退出循环,收集到的文本为空,永远不会触发阈值转换

可能的修复方向:

  • 将 TTS dual_output 的链结构改为 [Plain, Record, ...](Plain 在前),这样 T2I 能先收集到文本
  • 或者让 T2I 的聚合逻辑跳过非 Plain 组件继续收集所有 Plain 文本,而非遇到第一个非 Plain 就中断
  • 或者调整处理顺序,让 T2I 在 TTS 之前执行

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about AstrBot Share Dosu with your team

dosubot[bot] avatar May 20 '26 09:05 dosubot[bot]