Fix Language enum conversion at init time in base TTS/STT services#4024
Merged
markbackman merged 4 commits intomainfrom Mar 17, 2026
Merged
Fix Language enum conversion at init time in base TTS/STT services#4024markbackman merged 4 commits intomainfrom
markbackman merged 4 commits intomainfrom
Conversation
When a Language enum (e.g. Language.ES) is passed via settings=Service.Settings(language=Language.ES), it gets stored as-is without conversion to the service-specific code. The base _update_settings() handles this for runtime updates, but at init time apply_update() copies the raw enum. This causes API errors because services send the unconverted enum value. Add language conversion in TTSService.__init__ and STTService.__init__ after super().__init__(), using the subclass language_to_service_language() via normal method resolution.
Now that the base TTSService and STTService handle Language enum conversion at init time, subclasses no longer need to convert in their own __init__ methods. Remove conversion calls from hardcoded defaults, params paths, and deprecated direct arg paths across 22 service files. Services just pass raw Language enums and let the base class convert via language_to_service_language() polymorphic dispatch.
aconchillo
approved these changes
Mar 17, 2026
Contributor
|
Much cleaner! |
kompfner
reviewed
Mar 23, 2026
Contributor
kompfner
left a comment
There was a problem hiding this comment.
Just got around to seeing this. This is a very nice improvement. The init-time conversions scattered everywhere really bugged me.
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.
Summary
Languageenum values not being converted to service-specific codes when passed viasettings=Service.Settings(language=Language.ES)at init time. This caused API errors (e.g. 400 from Rime) because the raw enum was sent instead of the expected language code (e.g."spa"). Runtime updates viaUpdateSettingsFramewere unaffected.TTSService.__init__andSTTService.__init__, using the subclass'slanguage_to_service_language()via normal Python method resolution.__init__methods (hardcoded defaults, deprecatedparamspaths, deprecated direct arg paths). Subclasses now just pass rawLanguageenums and let the base class convert.languagearg. See 0ec5f5eTesting
uv run ruff check— passesuv run pytest— all 1030 tests pass🤖 Generated with Claude Code