For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
CommunityAPI StatusAPI PricingSign Up
DocumentationAPI ReferencesCookbookIntegrationDeveloper Tools
DocumentationAPI ReferencesCookbookIntegrationDeveloper Tools
  • Getting Started
    • Welcome
    • Quickstart
    • SDKs & Libraries
    • Building for Indian Languages
    • Models
    • Credits & Rate Limits
    • Errors & Troubleshooting
    • Talk to us
    • Pricing
    • Changelog
  • API Guides & Tutorials
      • Overview
      • Which API to Use
      • Rest API
      • Pronunciation Dictionary
      • Best Practices
        • Set the Language
        • Change the Speaker Voice
        • Adjust the Tone
        • Adjust the Speed
        • Adjust the Loudness
        • Set the Sample rate
        • Enable Text Preprocessing
        • Set audio format for output
        • Set bitrate for output
        • Set maximum length for sentence splitting
        • Set buffer size to start processing
LogoLogo
CommunityAPI StatusAPI PricingSign Up
On this page
  • Supported values:
  • Example Code
API Guides & TutorialsText to SpeechHow-to

How to set the sample rate (audio quality)

||View as Markdown|
Was this page helpful?
Previous

How to enable text preprocessing

Next
Built with

The speech_sample_rate parameter controls the audio quality and size of the generated output.

It is optional — if omitted, the default value is 24000 Hz (premium quality).

Supported values:

Sample Rate (Hz)Audio Quality DescriptionAvailability
8000Basic telephony qualityAll models & modes
16000Good quality voiceAll models & modes
22050High-quality audio (default for v2)All models & modes
24000Premium audio quality (default for v3)All models & modes
32000Broadcast qualitybulbul:v3 REST API only
44100CD quality audiobulbul:v3 REST API only
48000Professional/Studio qualitybulbul:v3 REST API only

Important: Sample rates above 24000 Hz (32000, 44100, 48000) are only available with bulbul:v3 via the REST API. They are not supported in streaming mode.

Example Code

Rest API
Streaming API
1from sarvamai import SarvamAI
2from sarvamai.play import save
3
4# Initialize the REST client
5client = SarvamAI(api_subscription_key="YOUR_SARVAM_API_KEY")
6
7# Generate speech using REST
8audio = client.text_to_speech.convert(
9 text="Welcome to Sarvam AI!",
10 model="bulbul:v3",
11 target_language_code="en-IN",
12 speech_sample_rate=24000 # Set premium audio quality
13)
14save(audio, "output1.wav")