Skip to content

fix(voice-call): use ?? instead of || for TTS speed config default#39318

Closed
ql-wade wants to merge 1 commit intoopenclaw:mainfrom
ql-wade:fix/issue-39285-tts-speed-nullish-coalescing
Closed

fix(voice-call): use ?? instead of || for TTS speed config default#39318
ql-wade wants to merge 1 commit intoopenclaw:mainfrom
ql-wade:fix/issue-39285-tts-speed-nullish-coalescing

Conversation

@ql-wade
Copy link
Copy Markdown
Contributor

@ql-wade ql-wade commented Mar 8, 2026

Fixes #39285

Use nullish coalescing operator (??) instead of logical OR (||) for TTS speed config default value.

This allows users to set speed to 0, which is a valid value, without it being treated as falsy and falling back to the default.

@openclaw-barnacle openclaw-barnacle bot added channel: voice-call Channel integration: voice-call size: XS labels Mar 8, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 8, 2026

Greptile Summary

This PR makes a targeted, single-line fix replacing the logical OR (||) operator with nullish coalescing (??) when resolving the TTS speed default in OpenAITTSProvider. This is a semantically correct improvement — ?? only falls back to 1.0 when config.speed is null or undefined, whereas || would also fall back when speed is 0 (falsy), silently overriding an explicit user value.

Changes:

  • extensions/voice-call/src/providers/tts-openai.ts (line 85): config.speed || 1.0config.speed ?? 1.0

Notes:

  • The fix is correct and is the idiomatic TypeScript/JavaScript pattern for numeric defaults.
  • The PR description's claim that "speed of 0 is a valid value" is slightly inaccurate — the code's own JSDoc and OpenAI's API both document the valid range as 0.25 to 4.0, so passing 0 would result in an API error regardless. The real value of the fix is preventing any explicitly-provided falsy-but-intended number from being silently discarded.
  • model and voice still use || at lines 82–84, which is acceptable for strings since an empty string is not a meaningful value in those contexts.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, correct fix with no risk of regression.
  • The change is a single-line swap of || to ??, which is semantically correct for a numeric default. It cannot break any existing behavior for valid input values (0.25–4.0), and it fixes the edge case where a user explicitly passes a falsy number and has it silently overridden. No logic is restructured, no new dependencies are introduced.
  • No files require special attention.

Comments Outside Diff (1)

  1. extensions/voice-call/src/providers/tts-openai.ts, line 37-38 (link)

    PR description slightly mischaracterizes the valid range

    The PR description states "This allows users to set speed to 0, which is a valid value", but the JSDoc on line 37 documents the range as 0.25 to 4.0, matching OpenAI's API constraint. A speed of 0 would be rejected by the API.

    The fix itself is still correct and valuable — using ?? is the right operator for numeric defaults because it avoids false-positive fallbacks for any explicitly-passed falsy number (e.g. 0 being treated as "not set"). But the PR description's justification is slightly misleading. Consider updating the description or the JSDoc to clarify the actual scenario being fixed.

Last reviewed commit: 0bf0cd3

@steipete
Copy link
Copy Markdown
Contributor

steipete commented Mar 8, 2026

Landed on main.

What shipped:

  • switch the voice-call OpenAI TTS speed default from || to ?? so explicit speed: 0 is preserved
  • add regression coverage for explicit zero and default fallback behavior
  • updated CHANGELOG.md
  • ran pnpm lint, pnpm build, and pnpm test

Landed commit:

Source PR commit:

Thanks @ql-wade.

@steipete steipete closed this Mar 8, 2026
mcaxtr pushed a commit to mcaxtr/openclaw that referenced this pull request Mar 8, 2026
Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
Saitop pushed a commit to NomiciAI/openclaw that referenced this pull request Mar 8, 2026
Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
GordonSH-oss pushed a commit to GordonSH-oss/openclaw that referenced this pull request Mar 9, 2026
Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
jenawant pushed a commit to jenawant/openclaw that referenced this pull request Mar 10, 2026
Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
dhoman pushed a commit to dhoman/chrono-claw that referenced this pull request Mar 11, 2026
Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
senw-developers pushed a commit to senw-developers/va-openclaw that referenced this pull request Mar 17, 2026
Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
V-Gutierrez pushed a commit to V-Gutierrez/openclaw-vendor that referenced this pull request Mar 17, 2026
Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
alexey-pelykh pushed a commit to remoteclaw/remoteclaw that referenced this pull request Mar 22, 2026
Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
(cherry picked from commit 442f2c3)
alexey-pelykh added a commit to remoteclaw/remoteclaw that referenced this pull request Mar 22, 2026
… CI fixes (#1794)

* fix: honor explicit Synology Chat rate-limit env values

Landed from contributor PR openclaw#39197 by @scoootscooob.

Co-authored-by: scoootscooob <[email protected]>
(cherry picked from commit af9d76b)

* fix: honor zero-valued voice-call STT settings

Landed from contributor PR openclaw#39196 by @scoootscooob.

Co-authored-by: scoootscooob <[email protected]>
(cherry picked from commit 28b72e5)

* fix: honor explicit OpenAI TTS speed values

Landed from contributor PR openclaw#39318 by @ql-wade.

Co-authored-by: ql-wade <[email protected]>
(cherry picked from commit 442f2c3)

* Voice Call: allowlist realtime STT api key fixtures

(cherry picked from commit b8b6569)

* Voice Call: read TTS internals in tests

(cherry picked from commit b1f7cf4)

* Voice Call: read realtime STT internals in tests

(cherry picked from commit 244aabb)

* test: fix gate regressions

(cherry picked from commit 56cd008)

* refactor: normalize voice-call runtime defaults

(cherry picked from commit 3087893)

* refactor: preserve explicit mock voice-call values

(cherry picked from commit f6c7ff3)

* fix(ci): resolve type regressions on main

(cherry picked from commit f721141)

* refactor(voice-call): share tts deep merge

(cherry picked from commit ed43743)

* fix: land openclaw#33992 from @darkamenosa

Co-authored-by: Tom <[email protected]>
(cherry picked from commit fcdc1a1)

* fix(ci): repair zalouser CI failures

(cherry picked from commit 06ffef8)

* fix: resolve cherry-pick type errors in zalouser extension

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* fix: resolve cherry-pick type error in voice-call config test — adapt SecretRef to string apiKey

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: scoootscooob <[email protected]>
Co-authored-by: ql-wade <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Co-authored-by: Tom <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: voice-call Channel integration: voice-call size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: voice-call TTS speed config uses || instead of ?? (same class as #39191)

2 participants