Skip to content

fix: add checks to return None if STT or TTS providers are disabled in config#7363

Merged
Soulter merged 1 commit intoAstrBotDevs:masterfrom
machinad:fix--add-checks-to-return-None-if-STT-or-TTS-providers-are-disabled-in-config
Apr 5, 2026
Merged

fix: add checks to return None if STT or TTS providers are disabled in config#7363
Soulter merged 1 commit intoAstrBotDevs:masterfrom
machinad:fix--add-checks-to-return-None-if-STT-or-TTS-providers-are-disabled-in-config

Conversation

@machinad
Copy link
Copy Markdown
Contributor

@machinad machinad commented Apr 4, 2026

当用户在模型服务商添加了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的提供商实例了,毕竟总开关都关闭了嘛。

  • This is NOT a breaking change. / 这不是一个破坏性变更。

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.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Bug Fixes:

  • Prevent repeated provider-not-found errors when STT or TTS global switches are off but a default provider ID remains configured.

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Apr 4, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot bot added the area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. label Apr 4, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 5, 2026
@Soulter Soulter merged commit d8f8462 into AstrBotDevs:master Apr 5, 2026
7 checks passed
@machinad machinad deleted the fix--add-checks-to-return-None-if-STT-or-TTS-providers-are-disabled-in-config branch April 5, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants