Create a new instance of Sarvam AI TTS.
apiKey must be set to your Sarvam API key, either using the argument or by setting the
SARVAM_API_KEY environment variable.
Returns this TTS's capabilities
Get the model name/identifier for this TTS instance.
The model name if available, "unknown" otherwise.
Plugins should override this property to provide their model information.
Returns the channel count of audio frames returned by this TTS
Get the provider name for this TTS instance.
The provider name if available, "unknown" otherwise.
Plugins should override this property to provide their provider information.
Returns the sample rate of audio frames returned by this TTS
Release idle pooled provider connections without closing the TTS.
The framework calls this once nothing uses the TTS any more: every activity and session that
uses an instance counts as a user, and the last one to close, or an Agent.updateOptions
that swaps the instance out, triggers the release. Those connections would otherwise sit idle
until the process exits.
Nothing in flight is interrupted: an in-flight synthesis keeps its connection, which then
closes when it finishes instead of rejoining the pool. The TTS stays usable and reconnects
on the next synthesis.
Providers without a connection pool need not override this.
Returns a SynthesizeStream that can be used to push text and receive audio data
Synthesize text to audio using Sarvam AI TTS.
Text to synthesize (max 2500 chars for v3, 1500 for v2)
Optional connOptions: APIConnectOptionsAPI connection options
Optional abortSignal: AbortSignalAbort signal for cancellation
A chunked stream of synthesized audio
Update TTS options after initialization.
When the model changes, only truly shared fields (apiKey, targetLanguageCode, pace, sampleRate, baseURL) carry over. Model-specific fields (speaker, pitch, loudness, temperature, dictId, enablePreprocessing) are dropped so resolveOptions re-applies the correct defaults for the new model.
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.