An instance of a text-to-speech adapter.

Remarks

This class is abstract, and as such cannot be used directly. Instead, use a provider plugin that exports its own child TTS class, which inherits this class's methods.

Hierarchy (view full)

Constructors

  • Create a new instance of Sarvam AI TTS.

    Parameters

    Returns TTS

    Remarks

    apiKey must be set to your Sarvam API key, either using the argument or by setting the SARVAM_API_KEY environment variable.

Properties

label: string = 'sarvam.TTS'

Accessors

  • get capabilities(): TTSCapabilities
  • Returns this TTS's capabilities

    Returns TTSCapabilities

  • get numChannels(): number
  • Returns the channel count of audio frames returned by this TTS

    Returns number

  • get sampleRate(): number
  • Returns the sample rate of audio frames returned by this TTS

    Returns number

Methods

  • Returns Promise<void>

  • Synthesize text to audio using Sarvam AI TTS.

    Parameters

    • text: string

      Text to synthesize (max 2500 chars for v3, 1500 for v2)

    • Optional connOptions: APIConnectOptions

      API connection options

    • Optional abortSignal: AbortSignal

      Abort signal for cancellation

    Returns ChunkedStream

    A chunked stream of synthesized audio

  • Update TTS options after initialization.

    Parameters

    Returns void

    Remarks

    When the model changes, only truly shared fields (apiKey, targetLanguageCode, pace, sampleRate, baseURL) carry over. Model-specific fields (speaker, pitch, loudness, temperature, enablePreprocessing) are dropped so resolveOptions re-applies the correct defaults for the new model.