Skip to content

feat(smallestai): update TTS plugin for Lightning v3.1 Pro and WebSocket streaming#5799

Merged
tinalenguyen merged 7 commits into
livekit:mainfrom
harshitajain165:feat/smallest-tts-lightning-v3-1-pro
May 29, 2026
Merged

feat(smallestai): update TTS plugin for Lightning v3.1 Pro and WebSocket streaming#5799
tinalenguyen merged 7 commits into
livekit:mainfrom
harshitajain165:feat/smallest-tts-lightning-v3-1-pro

Conversation

@harshitajain165

@harshitajain165 harshitajain165 commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add lightning_v3.1_pro model (premium 44.1 kHz pool, curated American, British, and Indian voices)
  • Resolve default voice from model — meher for Pro, sophia for standard
  • Rename lightning-v3.1lightning_v3.1 to match updated API model ID notation
  • Remove lightning-v2 (deprecated) and its exclusive params (consistency, similarity, enhancement)
  • Switch TTS endpoint from /{model}/get_speech to unified /tts; model now sent as body param
  • Update TTSEncoding: mulawulaw to match new API spec
  • Replace HTTP POST with persistent WebSocket streaming (wss://api.smallest.ai/waves/v1/tts/live) backed by ConnectionPool for significantly lower latency

Test plan

  • Lint, format, mypy — all pass
  • 8 existing unit tests pass
  • 4 live agent sessions verified: conn_reused=True, audio delivered correctly

…ified endpoint

- Add lightning_v3.1_pro model (premium 44.1 kHz pool, curated voice catalog)
- Rename lightning-v3.1 → lightning_v3.1 to match updated API model ID notation
- Remove lightning-v2 (deprecated) and its exclusive params (consistency, similarity, enhancement)
- Switch TTS endpoint from /{model}/get_speech to unified /tts; model now sent as body param
- Update TTSEncoding: mulaw → ulaw to match new API spec

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional findings.

Open in Devin Review

devin-ai-integration[bot]

This comment was marked as resolved.

…cy TTS

Switch the agent pipeline path from HTTP POST (/tts) to persistent WebSocket
streaming (/tts/live) backed by a ConnectionPool.

- Add SynthesizeStream using wss://api.smallest.ai/waves/v1/tts/live
- ConnectionPool keeps the WebSocket alive across turns (conn_reused=True)
- prewarm() pre-establishes the connection before the first user turn
- Keep ChunkedStream (HTTP POST) for direct synthesize() calls
- Change capabilities to streaming=True so the agent pipeline uses stream()

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment on lines +289 to +292
) from None
except APIStatusError:
raise
except Exception as e:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 SynthesizeStream._run catches APIStatusError but not APIConnectionError, causing error message loss

The exception handler at lines 289-292 catches APIStatusError and re-raises it, but does not catch APIConnectionError (or its parent APIError). When _run_ws raises APIConnectionError at livekit-plugins/livekit-plugins-smallestai/livekit/plugins/smallestai/tts.py:343-345 (e.g., "SmallestAI TTS error: {message}"), this falls through to the generic except Exception as e: raise APIConnectionError() from e handler, which wraps it in a new APIConnectionError("Connection error.") — discarding the specific error message. The established pattern (used by Deepgram at livekit-plugins/livekit-plugins-deepgram/livekit/plugins/deepgram/tts.py:295) is to catch APIError (the common base class) rather than just APIStatusError.

Suggested change
) from None
except APIStatusError:
raise
except Exception as e:
except APIStatusError:
raise
except APIConnectionError:
raise
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@harshitajain165 harshitajain165 changed the title feat(smallestai): update TTS plugin for Lightning v3.1 Pro and unified endpoint feat(smallestai): WebSocket streaming TTS with ConnectionPool for low-latency synthesis May 28, 2026
@harshitajain165 harshitajain165 changed the title feat(smallestai): WebSocket streaming TTS with ConnectionPool for low-latency synthesis feat(smallestai): update TTS plugin for Lightning v3.1 Pro and WebSocket streaming May 28, 2026
@harshitajain165

Copy link
Copy Markdown
Contributor Author

Hey @tinalenguyen
Would love a review on this when you get a chance! This PR updates the SmallestAI TTS plugin with two things: adds lightning_v3.1_pro as the default model and switches the agent pipeline from HTTP POST to WebSocket streaming via ConnectionPool

@tinalenguyen tinalenguyen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tested it and it lgtm, thank you!

@tinalenguyen tinalenguyen merged commit d0b8d81 into livekit:main May 29, 2026
17 checks passed
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.

2 participants