fix: add checks to return None if STT or TTS providers are disabled in config#7363
Merged
Soulter merged 1 commit intoAstrBotDevs:masterfrom Apr 5, 2026
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
enablechecks treat a missingenablekey the same asFalse, which may change behavior for existing configs that omit this flag; consider usingconfig[...].get('enable', True)or checking explicitly forFalseto preserve current defaults. - The STT and TTS branches now share very similar enable/
provider_idlogic; consider extracting a small helper to reduce duplication and keepget_using_providereasier to maintain.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `enable` checks treat a missing `enable` key the same as `False`, which may change behavior for existing configs that omit this flag; consider using `config[...].get('enable', True)` or checking explicitly for `False` to preserve current defaults.
- The STT and TTS branches now share very similar enable/`provider_id` logic; consider extracting a small helper to reduce duplication and keep `get_using_provider` easier to maintain.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the provider manager to check for an 'enable' flag within the speech-to-text and text-to-speech configuration settings before attempting to retrieve a provider. If the feature is disabled, the method now correctly returns None. I have no further feedback to provide.
Soulter
approved these changes
Apr 5, 2026
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
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.
当用户在模型服务商添加了tts或stt服务,但是因为没有安装依赖等导致服务不可用时,这时用户如果在普通配置-ai配置-启动文本转语音(打开)-默认文本转语音模型(选择例如edge-tts)后会发现服务无法运行,此时如果用户只是单纯关掉tts\stt的总开关而没有清除默认模型选择项的话,就会导致astrbot/core/provider/manager.py的provider_id(例如edge-tts)仍然会保留,这时消息平台每一次发起对话请求后台都会输出日志:"没有找到 ID 为edge-tts的提供商,这可能是由于您修改了提供商(模型)ID 导致的。"即便用户已经关掉了tts/stt的总开关或者已经在模型服务商处已经删除掉了模型服务,但因为在ai配置-启动文本转语音(关闭)-默认文本转语音模型处未清除掉模型名称而导致日志仍在在输出:"没有找到 ID 为edge-tts的提供商,这可能是由于您修改了提供商(模型)ID 导致的。"
Modifications / 改动点
在astrbot/core/provider/manager.py的get_using_provider函数中分别对tts和stt提供商引入tts\stt的总开关判断,当总开关关闭时就直接不获取tts/stt的提供商实例了,毕竟总开关都关闭了嘛。
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in
requirements.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Bug Fixes: