Skip to content

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

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

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

Conversation

@Sirius1942
Copy link
Copy Markdown

Fixes #39285

Use nullish coalescing (??) instead of logical OR (||) for the speed default value in the OpenAI TTS provider.

Problem

The current code uses ||, which treats 0 as falsy. While the OpenAI API minimum speed is 0.25, using ?? is more correct and consistent with the fixes in #39190 and #39191.

Solution

Changed:

this.speed = config.speed || 1.0;

To:

this.speed = config.speed ?? 1.0;

Impact

Low — defensive fix for consistency and correctness.

Fixes openclaw#39285

Use nullish coalescing (??) instead of logical OR (||) for the speed
default value. This prevents falsy numeric values (like 0) from being
incorrectly replaced with the default.

Consistent with fixes in openclaw#39190 and openclaw#39191.
@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 two complementary changes to the OpenAI TTS provider:

  1. Speed config fix (line 84): Replaces || with ?? (nullish coalescing) when applying the default speed value of 1.0. This is semantically correct because config.speed is typed as number | undefined. The change ensures that an explicitly provided 0 is not incorrectly overridden as falsy — only null or undefined will trigger the fallback.

  2. Function relocation: Extracts pcmToMulaw and linearToMulaw utility functions from tts-openai.ts to telephony-audio.ts for better code organization, with the import properly updated.

The changes are low-risk and correct. The model and voice fields on lines 82–83 continue to use || for their defaults, which is acceptable (empty strings are invalid inputs regardless). No other logic is affected.

Confidence Score: 5/5

  • This PR is safe to merge — the nullish coalescing fix is correct and the function relocation is properly executed with imports maintained.
  • The speed config change from || to ?? is semantically correct and solves the edge case where an explicitly passed 0 would be incorrectly overridden. The function relocation to telephony-audio.ts is a low-risk refactor that properly maintains imports. No files are broken, no logic is altered beyond the intended fix, and the change is minimal and well-scoped. The model and voice defaults can remain with || since empty strings are invalid inputs regardless.
  • No files require special attention

Last reviewed commit: ce3b961

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