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.
🛠 Prerequisites
Before running this, ensure you have:
- Python 3.7 or higher
- Python packages:
sarvamai
Install the required package using pip:
📦 Import Required Libraries
🔑 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.
📄 Example Text Input
⚙️ API Parameters
🔁 Convert Text to Speech
▶️ Play or 💾 Save Audio
To play the output:
To save the output:
📤 Output
Running the above code saves a output.wav
file containing the speech.
✅ 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.
📚 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!