How to adjust the pitch (tone)

The pitch parameter controls the tone of the synthesized speech by making the voice deeper or sharper.

It is optional, and if omitted, the default value 0.0 (neutral pitch) is used.

  • Range: -0.75 (deeper voice) to 0.75 (sharper voice)
  • Default: 0.0 (neutral pitch)

Use this to make the voice sound either lower or higher depending on your preference or use case.

Example Code

1from sarvamai import SarvamAI
2from sarvamai.play import save
3
4# Initialize the REST client
5client = SarvamAI(api_subscription_key="YOUR_API_SUBSCRIPTION_KEY")
6
7# Generate speech using REST
8audio = client.text_to_speech.convert(
9 text="Welcome to Sarvam AI!",
10 model="bulbul:v2",
11 target_language_code="en-IN",
12 pitch=0.5 # Increase pitch for a sharper tone
13)
14save(audio, "output1.wav")