-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix: 修复"开启 TTS 时同时输出语音和文字内容"功能不可用的问题 #2900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
您好 - 我已审阅了您的更改,它们看起来很棒!
AI 代理提示
请解决此代码审查中的评论:
## 单独评论
### 评论 1
<location> `astrbot/core/pipeline/result_decorate/stage.py:188-192` </location>
<code_context>
- and tts_provider
and SessionServiceManager.should_process_tts_request(event)
):
+ if not tts_provider:
+ logger.warning(
+ f"会话 {event.unified_msg_origin} 未配置文本转语音模型。"
+ )
+ return
new_chain = []
for comp in result.chain:
</code_context>
<issue_to_address>
**建议:** 考虑向用户提示 TTS 提供商配置错误。
除了仅记录警告外,当 TTS 因缺少配置而不可用时,请考虑在会话中通知用户。
建议的实现:
```python
if not tts_provider:
logger.warning(
f"会话 {event.unified_msg_origin} 未配置文本转语音模型。"
)
# 向用户会话发送系统消息,提示TTS未配置
SessionServiceManager.send_system_message(
event,
"当前会话未配置文本转语音模型,无法进行语音合成。"
)
return
```
- 如果 `SessionServiceManager.send_system_message` 不存在,您将需要实现或使用适当的方法向会话中的用户发送系统消息。
- 调整消息发送函数和参数以符合您的代码库中用户/系统通知的约定。
</issue_to_address>
### 评论 2
<location> `astrbot/core/pipeline/preprocess_stage/stage.py:49-51` </location>
<code_context>
ctx = self.plugin_manager.context
stt_provider = ctx.get_using_stt_provider(event.unified_msg_origin)
if not stt_provider:
+ logger.warning(
+ f"会话 {event.unified_msg_origin} 未配置语音转文本模型。"
+ )
return
message_chain = event.get_messages()
</code_context>
<issue_to_address>
**建议:** 考虑针对缺失的 STT 提供商提供面向用户的反馈。
目前,只记录了一个警告。请在会话中添加面向用户的反馈,以阐明其请求未被处理的原因。
建议的实现:
```python
if not stt_provider:
logger.warning(
f"会话 {event.unified_msg_origin} 未配置语音转文本模型。"
)
# 用户可见的反馈
event.reply("当前会话未配置语音转文本模型,无法处理您的语音请求。")
return
```
如果您的事件对象没有 `reply` 方法,请将 `event.reply(...)` 替换为适当的方法以向用户/会话发送消息。根据您应用程序的语气和风格调整反馈消息。
</issue_to_address>Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Original comment in English
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `astrbot/core/pipeline/result_decorate/stage.py:188-192` </location>
<code_context>
- and tts_provider
and SessionServiceManager.should_process_tts_request(event)
):
+ if not tts_provider:
+ logger.warning(
+ f"会话 {event.unified_msg_origin} 未配置文本转语音模型。"
+ )
+ return
new_chain = []
for comp in result.chain:
</code_context>
<issue_to_address>
**suggestion:** Consider surfacing TTS provider misconfiguration to the user.
Instead of only logging a warning, consider notifying the user in-session when TTS is unavailable due to missing configuration.
Suggested implementation:
```python
if not tts_provider:
logger.warning(
f"会话 {event.unified_msg_origin} 未配置文本转语音模型。"
)
# 向用户会话发送系统消息,提示TTS未配置
SessionServiceManager.send_system_message(
event,
"当前会话未配置文本转语音模型,无法进行语音合成。"
)
return
```
- If `SessionServiceManager.send_system_message` does not exist, you will need to implement or use the appropriate method to send a system message to the user in-session.
- Adjust the message sending function and parameters to match your codebase's conventions for user/system notifications.
</issue_to_address>
### Comment 2
<location> `astrbot/core/pipeline/preprocess_stage/stage.py:49-51` </location>
<code_context>
ctx = self.plugin_manager.context
stt_provider = ctx.get_using_stt_provider(event.unified_msg_origin)
if not stt_provider:
+ logger.warning(
+ f"会话 {event.unified_msg_origin} 未配置语音转文本模型。"
+ )
return
message_chain = event.get_messages()
</code_context>
<issue_to_address>
**suggestion:** Consider user-facing feedback for missing STT provider.
Currently, only a warning is logged. Please add user-facing feedback in the session to clarify why their request was not processed.
Suggested implementation:
```python
if not stt_provider:
logger.warning(
f"会话 {event.unified_msg_origin} 未配置语音转文本模型。"
)
# 用户可见的反馈
event.reply("当前会话未配置语音转文本模型,无法处理您的语音请求。")
return
```
If your event object does not have a `reply` method, replace `event.reply(...)` with the appropriate method to send a message to the user/session. Adjust the feedback message as needed for your application's tone and style.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #2844
Motivation / 动机
Modifications / 改动点
修正配置点映射
Verification Steps / 验证步骤
Screenshots or Test Results / 运行截图或测试结果
Compatibility & Breaking Changes / 兼容性与破坏性变更
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies areintroduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml.Original summary in English
Summary by Sourcery
Fix the TTS dual-output feature by correcting config mappings, enhancing the toggle command, and adding provider checks with warning logs in the processing pipeline.
Bug Fixes:
Enhancements: