← Back to PRs

#22618: feat(tts): add OpenAI TTS speed parameter support

by useramuser open 2026-02-21 11:58 View on GitHub →
size: XS
Adds support for the speed parameter when using OpenAI TTS provider. The OpenAI TTS API supports a speed field (0.25–4.0) but it was never passed through — the parameter was silently dropped even when set via config or [[tts:speed=X]] directive. **Changes:** - ResolvedTtsConfig.openai + TtsDirectiveOverrides.openai: add speed field - Zod config schema: messages.tts.openai.speed (0.25–4.0, optional) - esolveTtsConfig(): read aw.openai?.speed, default 1 - openaiTTS() in ts-core.ts: accept speed param, include in API body - extToSpeech() + telephony path: pass speed through - parseTtsDirectives(): [[tts:speed=X]] now sets OpenAI speed alongside ElevenLabs Closes #12163 > Replaces #12177 (branch was accidentally deleted during rebase attempt) <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds OpenAI TTS speed parameter support (0.25–4.0) across config schema, type definitions, and runtime execution paths. The implementation correctly defaults to 1.0, validates config values, passes speed through both `textToSpeech()` and `textToSpeechTelephony()`, and only includes speed in the API request when it differs from the default (avoiding unnecessary API payload). - Config schema validation added with correct OpenAI range (0.25–4.0) - `ResolvedTtsConfig.openai.speed` and `TtsDirectiveOverrides.openai.speed` typed correctly - `resolveTtsConfig()` defaults to 1 when not specified - `openaiTTS()` accepts optional speed, conditionally includes in API body - `textToSpeech()` and `textToSpeechTelephony()` both pass speed to OpenAI - `[[tts:speed=X]]` directive now sets both ElevenLabs and OpenAI speed (constrained to 0.5–2.0 for consistency) <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The implementation is clean, follows existing patterns, adds proper type safety, includes appropriate validation, and only extends functionality without breaking changes. The speed parameter defaults to 1.0 (OpenAI's default), is properly typed throughout, and correctly passes through all code paths. The only consideration is a minor design choice about directive range constraints. - No files require special attention <sub>Last reviewed commit: a6f1cd2</sub> <!-- greptile_other_comments_section --> <sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub> <!-- /greptile_comment -->

Most Similar PRs