Skip to content

Fix Language enum conversion at init time in base TTS/STT services#4024

Merged
markbackman merged 4 commits intomainfrom
mb/fix-lang-enum-stt-tts
Mar 17, 2026
Merged

Fix Language enum conversion at init time in base TTS/STT services#4024
markbackman merged 4 commits intomainfrom
mb/fix-lang-enum-stt-tts

Conversation

@markbackman
Copy link
Copy Markdown
Contributor

@markbackman markbackman commented Mar 13, 2026

Summary

  • Fixed Language enum values not being converted to service-specific codes when passed via settings=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 via UpdateSettingsFrame were unaffected.
  • Centralized language conversion in the base TTSService.__init__ and STTService.__init__, using the subclass's language_to_service_language() via normal Python method resolution.
  • Removed redundant per-service language conversion from 22 subclass __init__ methods (hardcoded defaults, deprecated params paths, deprecated direct arg paths). Subclasses now just pass raw Language enums and let the base class convert.
  • Found two missing deprecations for language arg. See 0ec5f5e

Testing

  • uv run ruff check — passes
  • uv run pytest — all 1030 tests pass

🤖 Generated with Claude Code

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.
@markbackman markbackman marked this pull request as draft March 13, 2026 15:00
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 32.55814% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/pipecat/services/google/tts.py 0.00% 3 Missing ⚠️
src/pipecat/services/rime/tts.py 0.00% 3 Missing ⚠️
src/pipecat/services/asyncai/tts.py 0.00% 2 Missing ⚠️
src/pipecat/services/azure/tts.py 0.00% 2 Missing ⚠️
src/pipecat/services/cartesia/tts.py 0.00% 2 Missing ⚠️
src/pipecat/services/elevenlabs/tts.py 0.00% 2 Missing ⚠️
src/pipecat/services/neuphonic/tts.py 0.00% 2 Missing ⚠️
src/pipecat/services/sarvam/tts.py 0.00% 2 Missing ⚠️
src/pipecat/services/aws/stt.py 0.00% 1 Missing ⚠️
src/pipecat/services/aws/tts.py 0.00% 1 Missing ⚠️
... and 9 more
Files with missing lines Coverage Δ
src/pipecat/services/lmnt/tts.py 36.42% <100.00%> (+1.39%) ⬆️
src/pipecat/services/openai/stt.py 34.93% <ø> (ø)
src/pipecat/services/stt_service.py 35.76% <100.00%> (+1.32%) ⬆️
src/pipecat/services/tts_service.py 63.39% <100.00%> (+0.25%) ⬆️
src/pipecat/services/xtts/tts.py 46.83% <100.00%> (+2.09%) ⬆️
src/pipecat/services/aws/stt.py 34.41% <0.00%> (ø)
src/pipecat/services/aws/tts.py 46.15% <0.00%> (ø)
src/pipecat/services/azure/stt.py 15.38% <0.00%> (ø)
src/pipecat/services/camb/tts.py 3.44% <0.00%> (ø)
src/pipecat/services/elevenlabs/stt.py 33.74% <0.00%> (+0.30%) ⬆️
... and 14 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@markbackman markbackman marked this pull request as ready for review March 13, 2026 15:36
@markbackman markbackman requested a review from kompfner March 13, 2026 15:36
@aconchillo
Copy link
Copy Markdown
Contributor

Much cleaner!

@markbackman markbackman merged commit 53f49ac into main Mar 17, 2026
6 checks passed
@markbackman markbackman deleted the mb/fix-lang-enum-stt-tts branch March 17, 2026 01:08
Copy link
Copy Markdown
Contributor

@kompfner kompfner left a comment

Choose a reason for hiding this comment

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

Just got around to seeing this. This is a very nice improvement. The init-time conversions scattered everywhere really bugged me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants