How to adjust the pace (speed)

The pace parameter controls the speed at which the speech is delivered.

It is optional — if omitted, the default value is 1.0 (normal speed).

  • Valid range: 0.3 (slowest) to 3.0 (fastest)
  • Values < 1.0 slow the speech down; values > 1.0 speed it up.
  • Adjust this to speed up or slow down the voice according to your needs.
1# Import SarvamAI client and save helper
2from sarvamai import SarvamAI
3from sarvamai.play import save
1# Initialize the SarvamAI client with your API key
2client = SarvamAI(api_subscription_key="YOUR_API_SUBSCRIPTION_KEY")
1# Example1: Using default pace (normal speed)
2audio = client.text_to_speech.convert(
3 text="Welcome to Sarvam AI!",
4 model="bulbul:v2",
5 target_language_code="en-IN",
6 pace=1.0 #normal speed
7)
1#Example 2: Using selected pace (faster speech)
2audio = client.text_to_speech.convert(
3 text="Hello, how are you today?",
4 model="bulbul:v2",
5 target_language_code="en-IN",
6 pace=1.5 # Increase pace for faster speech
7)
1# Save the generated audio to a file
2save(audio, "output_pitch_up.wav")