From d0495eeef6cb3b259de8ad10709666b88a2d2d77 Mon Sep 17 00:00:00 2001 From: Paul Kompfner Date: Thu, 23 Apr 2026 21:08:47 -0400 Subject: [PATCH] fix(types): narrow voice in SpeechmaticsTTSSettings to disallow None After widening TTSSettings.voice to str | None | _NotGiven (so other TTS services can opt into None as a valid "no voice" state), pyright flagged Speechmatics' URL builder receiving str | None where it required str. Speechmatics has no "no voice" mode (the URL path includes the voice name), so override the inherited field in SpeechmaticsTTSSettings to str | _NotGiven. The call site stays as a plain assert_given(...) without an extra None check. --- src/pipecat/services/speechmatics/tts.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pipecat/services/speechmatics/tts.py b/src/pipecat/services/speechmatics/tts.py index a4f99d03f..519e6775e 100644 --- a/src/pipecat/services/speechmatics/tts.py +++ b/src/pipecat/services/speechmatics/tts.py @@ -43,6 +43,9 @@ class SpeechmaticsTTSSettings(TTSSettings): max_retries: Maximum number of retries for HTTP requests. """ + # Speechmatics requires a voice (the URL path includes it), so narrow + # the inherited TTSSettings.voice field to disallow None. + voice: str | _NotGiven = field(default_factory=lambda: NOT_GIVEN) max_retries: int | _NotGiven = field(default_factory=lambda: NOT_GIVEN)