Async TTS API Quickstart
Learn how to use PlayAI’s asynchronous Text-to-Speech API
This guide provides a step-by-step approach to using the PlayAI Text-to-Speech API to convert text into natural human-like sounding audio using the Async (non-streaming) API Endpoint.
In this example, we’ll have Dialog 1.0 create a simple audio from the given input text.
Prerequisites
- Access credentials (Secret key and User ID)
- Development environment for your chosen programming language
Steps
Set Up Environment Variables
Add your API key and user ID to your environment variables.
Configure API Access
Create a script with the following authentication setup for your chosen language:
Submit TTS Job
Create and submit your TTS job in your chosen language:
Poll Job Status
Monitor your job’s progress in your chosen language:
Download and Save Audio
Save the generated audio file in your chosen language:
Complete Code
Troubleshooting
If you encounter issues, check these common problems:
-
Authentication Issues:
- Verify your API key and user ID
- Confirm the
AUTHORIZATION
header includes “Bearer ” prefix
-
Job Status Polling:
- Ensure you’re using the correct job ID
- Check that the polling URL is properly formatted
- Verify the polling interval is appropriate for your use case
-
API Endpoint Errors:
- Verify the correct PlayAI’s Dialog 1.0 API endpoint URL
- Confirm the model name is correct
- Check that all required parameters are included in the request
-
Language-Specific Issues:
- JavaScript: Ensure
node-fetch
is installed for Node.js environments - Go: Check for proper error handling and response body closing
- Dart: Verify the
http
package is added to yourpubspec.yaml
- Swift: Make sure you’re running on macOS for file system access
- JavaScript: Ensure