Skip to content

fix: resolve raw language strings through Language enum for proper service conversion#4058

Merged
markbackman merged 2 commits intomainfrom
mb/improve-stt-tts-language-code-robustness
Mar 17, 2026
Merged

fix: resolve raw language strings through Language enum for proper service conversion#4058
markbackman merged 2 commits intomainfrom
mb/improve-stt-tts-language-code-robustness

Conversation

@markbackman
Copy link
Copy Markdown
Contributor

@markbackman markbackman commented Mar 17, 2026

Summary

  • Fixed raw language strings like "de-DE" silently failing when passed to TTS/STT services. Previously, raw strings bypassed the Language enum resolution logic and were sent directly to the provider API (e.g. ElevenLabs expects "de", not "de-DE"), causing no audio output with no error.
  • Raw strings are now converted to Language enums first so they go through the same resolve_language() path as enum values, properly resolving regional codes to service-expected formats.
  • Unrecognized language strings now log a warning instead of failing silently.
  • The fix applies to both TTSService and STTService base classes, covering both init-time and runtime update paths.

Testing

uv run pytest tests/test_service_language.py -v

23 tests covering all permutations of:

  • Input types: Language enum (base), Language enum (regional), raw string (base), raw string (regional), unrecognized string, None
  • Code paths: init-time settings, runtime _update_settings()
  • Service types: TTS and STT

🤖 Generated with Claude Code

…rvice conversion

Raw strings like "de-DE" passed as the language parameter to TTS/STT services
were bypassing the Language enum resolution logic, causing silent failures
(e.g. ElevenLabs expects "de" not "de-DE"). Now raw strings are first converted
to Language enums so they go through the same resolve_language() path, with a
warning logged for unrecognized strings.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/pipecat/services/stt_service.py 40.14% <100.00%> (+4.37%) ⬆️
src/pipecat/services/tts_service.py 65.06% <100.00%> (+1.66%) ⬆️

... and 4 files with indirect coverage changes

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

Copy link
Copy Markdown
Contributor

@filipi87 filipi87 left a comment

Choose a reason for hiding this comment

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

LGTM!

@markbackman markbackman merged commit 10b3bff into main Mar 17, 2026
6 checks passed
@markbackman markbackman deleted the mb/improve-stt-tts-language-code-robustness branch March 17, 2026 20:20
markbackman added a commit that referenced this pull request Mar 21, 2026
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.

2 participants