Skip to content

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

Open
subrih wants to merge 1 commit intoopenclaw:mainfrom
subrih:fix/tts-speed-nullish-coalescing
Open

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

Conversation

@subrih
Copy link
Copy Markdown

@subrih subrih commented Mar 8, 2026

Fixes #39285

What

Replace || with ?? (nullish coalescing) when setting the default TTS speed value in OpenAITTSProvider.

Why

|| treats any falsy value as "not set", so a speed of 0 would incorrectly fall back to 1.0. Using ?? ensures only null or undefined trigger the default — consistent with how numeric config values should be handled.

Change

extensions/voice-call/src/providers/tts-openai.ts:85

- this.speed = config.speed || 1.0;
+ this.speed = config.speed ?? 1.0;

AI-assisted (Claude) | Lightly tested | Fix is a defensive consistency change; valid speed range is 0.25–4.0

@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, correct fix to OpenAITTSProvider by replacing || with ?? (nullish coalescing) when defaulting config.speed to 1.0. This prevents a falsy numeric value like 0 from incorrectly triggering the fallback — consistent with how numeric configuration values should be handled.

  • The fix is logically sound: ?? defaults only on null/undefined, while || would have silently overridden an explicit speed: 0 (which, while outside the valid 0.25–4.0 range, should produce an API error rather than a silent override).
  • The remaining uses of || for model and voice (lines 82–84) are appropriate since those are string fields where an empty string is also a valid "not set" signal.
  • There is no range validation guard for speed (i.e., enforcing [0.25, 4.0]), but this is a pre-existing gap unrelated to this PR. Consider adding a guard in a follow-up to surface misconfiguration earlier than an API error.

Confidence Score: 5/5

  • This PR is safe to merge — the one-line change is correct, well-scoped, and introduces no regressions.
  • The fix is a straightforward and correct improvement to a single config default assignment. The ?? operator is semantically appropriate for numeric optional fields. No tests or interfaces are changed, and the rest of the file is unaffected.
  • No files require special attention.

Last reviewed commit: e7192e4

@subrih
Copy link
Copy Markdown
Author

subrih commented Mar 8, 2026

Both CI failures are pre-existing and unrelated to this change:

  • CI / check: formatting issue in src/discord/monitor/exec-approvals.test.ts — not in this diff
  • CI / secrets: false positives in test files (systemd.test.ts, connection-auth.test.ts, runner.ts) — none touched by this PR

Diff is a single line in extensions/voice-call/src/providers/tts-openai.ts. Happy to address in a follow-up if helpful, but keeping this PR scoped to the single fix.

@subrih subrih force-pushed the fix/tts-speed-nullish-coalescing branch from e7192e4 to 23fa9c1 Compare March 8, 2026 04:00
@subrih
Copy link
Copy Markdown
Author

subrih commented Mar 8, 2026

After rebasing onto upstream main, I can see this fix (?? instead of || for config.speed) is already present in the current main. Happy to close this if it's been addressed — or let me know if you'd still like to merge it.

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)

1 participant