Text-to-Speech Conversion using Bulbul Model
Overview
This guide demonstrates how to convert text into speech using the Sarvam AI Text-to-Speech API. The resulting audio files are saved as .wav
files.
1.Prerequisites
Before running this, ensure you have:
- Python 3.7 or higher
- Python packages:
sarvamai
Install the required package using pip:
2.Import Required Libraries
3.Set Up Your API Key
To use the TTS Bulbul API:
- Sign up at Sarvam AI Dashboard to get your API key.
- Replace the placeholder key in the code.
4.Example Text Input
5.API Parameters
6.Convert Text to Speech
7. Play or Save Audio
To play the output:
To save the output:
8.Output
Running the above code saves a output.wav
file containing the speech.
9.Conclusion
This MDX guide showed how to use Sarvam AI’s TTS API to convert Hindi text into lifelike speech. Customize the text, language, voice, and parameters to suit your application.
10.Additional Resources
- Documentation: docs.sarvam.ai
- Community Support: Join our Discord
🛡️ Note: Keep your API key safe and avoid committing it in public repositories.
🚀 Keep Building!