Skip to content

improvement(elevenlabs): wire stability and similarity_boost end-to-end#4679

Merged
waleedlatif1 merged 2 commits into
stagingfrom
waleedlatif1/validate-elevenlabs-integration
May 20, 2026
Merged

improvement(elevenlabs): wire stability and similarity_boost end-to-end#4679
waleedlatif1 merged 2 commits into
stagingfrom
waleedlatif1/validate-elevenlabs-integration

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Wired stability and similarityBoost end-to-end (block → tool → contract → proxy route → ElevenLabs voice_settings); previously the tool params were dropped at the contract boundary
  • Exposed both knobs in the block under advanced mode
  • Renamed tool param similaritysimilarityBoost to align with the ElevenLabs API field (similarity_boost) and Sim's unified TTS contract
  • Added explicit default to modelId dropdown, cleaned up redundant descriptions, removed duplicate ElevenLabsBlockResponse type, removed unused params arg on headers
  • Contract clamps stability / similarityBoost to 0–1

Type of Change

  • Improvement

Testing

Tested manually. bun run check:api-validation:strict, biome lint, and tsc --noEmit all clean.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped May 20, 2026 8:21pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 20, 2026

PR Summary

Medium Risk
Moderate risk because it changes request/validation and the payload sent to ElevenLabs (new voice_settings and renamed param), which could affect existing integrations if they still send similarity or out-of-range values.

Overview
Adds end-to-end support for ElevenLabs voice tuning by accepting stability and similarityBoost in the TTS API contract, forwarding them through the ElevenLabs tool/block, and sending them to ElevenLabs as voice_settings (with defaults when either knob is provided).

Renames the tool param from similarity to similarityBoost, exposes both fields in the ElevenLabs block as advanced inputs, sets a default modelId dropdown value, and simplifies types by aliasing ElevenLabsBlockResponse to ElevenLabsTtsResponse.

Reviewed by Cursor Bugbot for commit abf9443. Configure here.

Comment thread apps/sim/app/api/tools/tts/route.ts Outdated
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 20, 2026

Greptile Summary

This PR wires stability and similarityBoost end-to-end for the ElevenLabs TTS block — previously the values were accepted by the tool but silently dropped at the contract boundary before reaching the proxy route. It also renames similaritysimilarityBoost to align with the ElevenLabs similarity_boost API field and removes a duplicate type definition.

  • Contract fix: ttsToolBodySchema now declares stability and similarityBoost with z.coerce.number().min(0).max(1).optional(), and the route handler builds voice_settings only when at least one knob is set, filling defaults (0.5 / 0.75) for the absent field as required by the ElevenLabs API.
  • Block UI: Two short-input fields are exposed under advanced mode with a parseUnitInterval helper that guards against NaN/Infinity before forwarding values to the tool.
  • Cleanup: Duplicate ElevenLabsBlockResponse interface collapsed into a type alias of ElevenLabsTtsResponse; unused params arg removed from the headers factory.

Confidence Score: 5/5

Safe to merge — the end-to-end wiring is correct, the type rename is consistent across all five files, and the server-side contract properly validates the new fields.

The contract boundary fix is straightforward and well-scoped. All changed files are internally consistent: the tool, contract, route, block, and types all use the same similarityBoost name. The voice_settings construction correctly handles the partially-set case by filling in ElevenLabs-standard defaults. The only non-blocking finding is that the client-side parseUnitInterval helper accepts out-of-range values that are then rejected server-side, which is a minor UX gap rather than a data correctness issue.

No files require special attention. apps/sim/blocks/blocks/elevenlabs.ts has a minor range-check gap in parseUnitInterval but values outside [0, 1] are correctly rejected by the server contract.

Important Files Changed

Filename Overview
apps/sim/app/api/tools/tts/route.ts Correctly destructures stability and similarityBoost from the validated contract body; builds voice_settings only when at least one knob is present, filling in sensible defaults (0.5/0.75) for the absent field.
apps/sim/blocks/blocks/elevenlabs.ts Adds stability and similarityBoost advanced-mode inputs and a parseUnitInterval guard that filters NaN/Infinity; the guard does not enforce the [0, 1] range client-side.
apps/sim/lib/api/contracts/tools/media/tts.ts Adds stability and similarityBoost to ttsToolBodySchema with correct z.coerce.number().min(0).max(1).optional() constraints.
apps/sim/tools/elevenlabs/tts.ts Renames similaritysimilarityBoost throughout and removes the unused params argument from the headers factory.
apps/sim/tools/elevenlabs/types.ts Renames similaritysimilarityBoost and collapses the duplicate ElevenLabsBlockResponse interface into a type alias of ElevenLabsTtsResponse.

Sequence Diagram

sequenceDiagram
    participant UI as Block UI (elevenlabs.ts)
    participant Tool as ElevenLabs TTS Tool
    participant Route as /api/tools/tts
    participant EL as ElevenLabs API

    UI->>UI: "parseUnitInterval(stability)<br/>parseUnitInterval(similarityBoost)"
    UI->>Tool: "{ text, voiceId, modelId,<br/>stability, similarityBoost, apiKey }"
    Tool->>Route: "POST /api/tools/tts<br/>body: { ..., stability, similarityBoost }"
    Route->>Route: "ttsToolBodySchema.parse()<br/>z.coerce.number().min(0).max(1)"
    Route->>Route: "hasVoiceSetting?<br/>build voice_settings<br/>with defaults 0.5/0.75"
    Route->>EL: "POST /v1/text-to-speech/{voiceId}<br/>{ text, model_id, voice_settings? }"
    EL-->>Route: audio/mpeg
    Route-->>Tool: "{ audioUrl, audioFile }"
    Tool-->>UI: "{ success, output }"
Loading

Reviews (2): Last reviewed commit: "fix(elevenlabs): guard NaN in voice sett..." | Re-trigger Greptile

Comment thread apps/sim/blocks/blocks/elevenlabs.ts Outdated
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit abf9443. Configure here.

@waleedlatif1 waleedlatif1 merged commit 7e67855 into staging May 20, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/validate-elevenlabs-integration branch May 20, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant