Skip to main content
Version: 1.0.x

SmallestAI TTS

The SmallestAI TTS provider enables your agent to use SmallestAI's high-quality text-to-speech models for generating voice output.

Installation

Install the SmallestAI-enabled VideoSDK Agents package:

pip install "videosdk-plugins-smallestai"

Importing

from videosdk.agents.plugins import SmallestAITTS

Authentication

The Smallest AI plugin requires a Smallest AI API key.

Set SMALLEST_API_KEY in your .env file.

Example Usage

from videosdk.agents.plugins import SmallestAITTS
from videosdk.agents import Pipeline

# Initialize the SmallestAI TTS model
tts = SmallestAITTS(
# When SMALLEST_API_KEY is set in .env - DON'T pass api_key parameter
api_key="your-smallestai-api-key",
model="lightning",
voice_id="emily"
)

# Add tts to pipeline
pipeline = Pipeline(tts=tts)
note

When using .env file for credentials, don't pass them as arguments to model instances. The SDK automatically reads environment variables, so omit api_key from your code.

Configuration Options

  • api_key: (str) Your SmallestAI API key. Can also be set via the SMALLEST_API_KEY environment variable.
  • model: (str) The TTS model to use. Allowed values: "lightning", "lightning-large", "lightning-v2", "lightning-v3.1". Defaults to "lightning-v3.1".
  • voice_id: (str) The ID of the voice to use. Defaults to "magnus".
  • language: (str) The language to use. One of "en" or "hi". Defaults to "en".
  • sample_rate: (int) The output sample rate in Hz. One of 8000, 16000, 24000, 44100. Defaults to 24000.
  • speed: (float) Speech speed multiplier. Defaults to 1.0.
  • consistency: (float) Controls word repetition and skipping. Only supported in the lightning-v2 model. Defaults to 0.5.
  • similarity: (float) Controls similarity to the reference audio. Only supported in the lightning-v2 model. Defaults to 0.0.
  • enhancement: (float) Output enhancement level. Only supported in the lightning-v2 model. Defaults to 1.0.
  • sentence_streaming: (bool) When True, upstream tokens are batched into sentence-sized requests so audio for a sentence starts playing while the next is still being produced. Defaults to True.
  • base_url: (str) HTTPS base URL for the Smallest AI Waves API. Defaults to "https://api.smallest.ai/waves/v1".
  • timeout: (float) Per-request HTTP timeout in seconds. Defaults to 30.0.
  • enable_streaming: (bool) When True, opens a persistent WebSocket to the streaming endpoint; when False, falls back to per-segment HTTP POSTs. Streaming is only valid for lightning-v3.1. Defaults to True.
  • max_connection_age_sec: (float) WebSocket only. Refresh the connection after this many seconds to avoid idle/session limits. Defaults to 300.0.
  • complete_backoff_ms: (int) WebSocket only. Server-side delay after the last audio chunk before status: complete is emitted. Defaults to 0.
  • max_buffer_flush_ms: (int) WebSocket only. Server-side flush trigger — max wait for more input before generating output. Defaults to 0.

Additional Resources

The following resources provide more information about using Smallest AI with VideoSDK Agents SDK.

Got a Question? Ask us on discord