Text-to-Speech
Text-to-Speech Quickstart
Get started with PlayAI Text-to-Speech in minutes
This quickstart guide will help you programmatically convert text into audio using PlayAI’s models.
Check out our Playground for a quick way to try out our voices without writing any code.
Prerequisites
- Access credentials (your secret key and user ID)
Converting Text to Speech
1
Set Up Your Environment
First, let’s set up your API credentials securely:
2
Create Your First Audio
Run the following script to create your first audio.
Understanding the Code
Let’s break down the key components:
- Authentication: We use environment variables for secure credential management
- Request Headers: Include your API key and user ID for authentication
- Request Body:
model
: Set toPlayDialog
for our advanced TTS modeltext
: The text you want to convert to speechvoice
: URL to the voice manifest (using a default voice for this example)outputFormat
: The audio format (wav or mp3)
Next Steps
- Try Different Voices: Explore our voice library
- Create Multi-speaker Dialogues: Learn how to create conversations
- Stream Audio: Check out our WebSocket API for real-time streaming
Troubleshooting
Common issues and solutions:
-
Authentication Errors
- Verify your API key and user ID are correct
- Ensure the ‘Bearer ’ prefix is included in the Authorization header
-
API Errors
- Check the API endpoint URL is correct
- Verify the model name is
PlayDialog
- Ensure your text input is valid
-
File Saving Issues
- Check write permissions in your working directory
- Verify sufficient disk space
Need more help? Check out our troubleshooting guide or error messages.
Was this page helpful?