Frequently asked questions
What Python version is required?
The OpenAI Python SDK works with your standard Python environment. No specific version is mandated beyond what the SDK supports. You simply configure the base URL to https://api.musang188.cc/v1 and use the standard library methods to send text and receive audio files.
Do I need an API key?
Yes. You must sign up at /get-api-key/ to obtain a Bearer token. Pass this as Authorization: Bearer tts-... in your requests. One active key per account is issued; you can generate a new one anytime, which immediately invalidates the old key.
How do I install the library?
Install the OpenAI Python package via pip: pip install openai. Since our API mirrors the OpenAI speech endpoint, you can reuse existing code by changing the base_url to https://api.musang188.cc/v1 and providing your SonicPress API key for authentication.
Can I run this on shared hosting?
Yes, provided your hosting environment supports Python and outbound HTTPS requests. Since the API handles synthesis, you only need to send JSON payloads. Ensure your server allows connections to api.musang188.cc and has sufficient memory to handle the response audio data.
How do I save the audio file?
The API returns the audio file directly in the response. Save the binary content to your WordPress media library or a local directory. Supported formats include mp3, wav, opus, flac, and pcm. You can then enqueue the file in your WordPress theme or plugin.
What if the API is down?
We do not offer an SLA or uptime guarantee. If the API is unavailable, requests will fail. Failed requests are free, so no credit is deducted. You should implement retry logic in your Python script to handle transient network issues or server errors gracefully.
Can I generate audio in the background?
The API processes requests sequentially. Under load, a request may wait in a queue. For long articles, split text into 4096-character parts and join the resulting audio files. You can trigger this process via a WordPress cron job or a background task queue.
How do I handle special characters?
Send the text as a standard JSON string in the input field. The API handles encoding automatically. Ensure your Python script properly escapes JSON strings. The API does not support SSML, so special characters are treated as plain text without custom pronunciation rules or phoneme dictionaries.
Is there a limit to file size?
There is no strict file size limit, but input text is limited to 4096 characters per request. For longer articles, split the text into chunks, generate audio for each, and concatenate the files. Generation speed is roughly real-time, so longer texts take longer to process.
Can I use this with Gutenberg?
Yes. Generate the audio file using Python, then upload it to your WordPress media library. Use the Gutenberg Audio block to embed the file. You can automate this workflow by saving the generated audio to a specific folder and importing it into your media library.
How do I embed the audio player?
Upload the generated audio file (mp3, wav, opus, flac, or pcm) to your WordPress media library. Then, use the native WordPress Gutenberg Audio block or a shortcode to embed the player. The player will play the synthetic speech file directly in the browser.
Do I need a server for this?
No dedicated server is required for synthesis, as it is cloud-based. You only need a Python environment to send requests to api.musang188.cc. Your WordPress site serves the final audio file, which can be hosted on your existing web server or CDN.
Can I automate this daily?
Yes. Write a Python script that fetches new posts, generates audio, and uploads them. Schedule this script using a cron job on your server or a task scheduler. Monitor your usage via the dashboard to ensure you stay within your rate limits and balance.
What happens if I exceed limits?
The rate limit is 60 requests per minute per key. If you exceed this, requests may be delayed or rejected. Failed requests are free. If you run out of balance, new requests will fail until you top up via USDT (TRC-20) on the TRON network.
Prerequisites for Your Project
Before writing any code, ensure your development environment is ready. You need Python 3.8 or higher installed on your machine. An active internet connection is essential because the API processes requests over the cloud, so offline generation is not possible.
You also need a valid API key from your SonicPress account. This key authenticates your requests and tracks usage against your balance. Without it, the Python script cannot access the speech generation endpoint.
Python 3.8 or higher
Ensure your local environment runs Python 3.8 or a newer version. This version supports the necessary libraries for handling HTTP requests and JSON data efficiently.
- Compatible with Windows, macOS, and Linux
Internet connection for API calls
Since the speech synthesis happens on our servers, your script must have reliable internet access. A stable connection ensures smooth data transfer for text input and audio output.
API key from your account
Retrieve your unique key from the /get-api-key/ page. Keep it secure, as it grants access to your account balance and usage limits.
- Found under the 'API Key' section
- Starts with 'tts-...'
Installing Required Libraries
To generate audio from your blog posts, you need a way to communicate with the API. You can use the standard requests library or the official OpenAI SDK, which works seamlessly by adjusting the base URL.
Install requests or OpenAI SDK
Run pip install requests or pip install openai in your terminal. Both libraries are lightweight and sufficient for sending JSON payloads and receiving binary audio data.
No other dependencies needed
The API handles all synthesis on the server side. You do not need to install heavy audio processing libraries or codec dependencies locally. Your script only needs to handle HTTP communication and file I/O.
Virtual environment recommended
We recommend using a Python virtual environment to isolate these dependencies. This prevents version conflicts with other WordPress plugins or Python scripts running on your server.
Constructing the API Request
To generate audio, you must send a POST request to the correct endpoint. The base URL is https://api.musang188.cc/v1, and the specific path for speech synthesis is /audio/speech. This endpoint accepts JSON payloads containing your text and configuration details.
Define the endpoint URL
Use the full URL https://api.musang188.cc/v1/audio/speech for your POST request. This endpoint processes your input text and returns an audio file in the format you specify.
Set the JSON body parameters
Construct a JSON object with the required fields: model, input, and voice. The input field holds your article text (max 4096 characters). Choose tts-1 or tts-1-hd for model. Select a voice like nova or aria from the 8 available presets. You can also set response_format (e.g., mp3), speed (0.25–4.0), and language if needed.
model: "tts-1" or "tts-1-hd"input: Your text string (up to 4096 chars)voice: One of 8 presets (e.g., "nova", "alloy")response_format: "mp3", "wav", "opus", "flac", or "pcm"
Add authentication header
Include your API key in the HTTP header. Use the format Authorization: Bearer tts-<your_key>. Replace <your_key> with the key found on your /get-api-key/ dashboard. Without this header, the request will return a 401 Unauthorized error.
Sending the Request
The API processes your text asynchronously but returns the audio file directly in the response body. You send a POST request to the speech endpoint with your authentication header and JSON payload.
Once the server receives your request, it validates the parameters and begins synthesis. You must wait for the HTTP response to confirm whether the generation succeeded or failed before proceeding to save the file.
Use POST method for speech generation
Send your request to https://api.musang188.cc/v1/audio/speech using the POST method. Include your Authorization: Bearer header and the JSON body containing the model, input, voice, and other parameters.
Ensure the request body matches the required schema. The endpoint accepts standard JSON formats, allowing you to use the official OpenAI Python SDK by simply adjusting the base URL.
- Endpoint: POST /v1/audio/speech
- Header: Authorization: Bearer tts-...
Wait for response status
Monitor the HTTP status code. A 200 OK indicates success, while 4xx errors indicate client issues (e.g., invalid key or missing parameters).
If the server returns a 5xx error, the request may have failed during synthesis. Failed requests are free, so you can retry without charge.
- 200: Success
- 4xx: Client error
- 5xx: Server error
Handle JSON response data
On success, the response body contains the audio file in the specified format (mp3, wav, etc.). Extract this binary data for storage.
Parse any error messages in the JSON response to understand why a request failed, such as exceeding character limits or invalid voice IDs.
- Response: Audio binary data
- Error: JSON details
Saving the Audio File
The API returns audio as binary data in the response body. You must write this raw bytes object directly to a file on your server’s disk. Do not decode the content to a string, as this corrupts the audio format. Ensure your script opens the file in binary write mode to preserve the integrity of the generated MP3, WAV, or FLAC file.
Write binary data to disk
Use your Python script to save the response content immediately. Open a file handle with 'wb' mode and write the response.content. This ensures the audio file is complete and playable. Avoid intermediate encoding steps that might alter the binary stream.
- Open file in binary write mode ('wb')
- Write response.content directly to disk
- Close the file handle to flush data
Name files appropriately
Generate filenames that are unique and descriptive. Include the post ID or a timestamp to prevent overwriting. Use the selected response format as the extension (e.g., .mp3 or .wav). This makes it easy to identify which audio belongs to which article in your storage directory.
- Include post ID or timestamp in filename
- Match extension to response_format (mp3, wav)
- Ensure uniqueness to avoid overwrites
Store in WordPress media library
Once the file is on disk, import it into your WordPress media library. This allows you to embed the audio easily using the standard HTML5 player. Use WP Media Library functions to add the file, ensuring it is accessible via a public URL for your blog readers.
- Import file to WordPress media library
- Use standard HTML5 audio embed codes
- Ensure public URL accessibility
Handling Errors Gracefully
When the API rejects a request, the Python script must immediately check the HTTP status code. A 4xx error usually indicates an authentication issue or invalid parameters, while 5xx errors suggest temporary server overload. Distinguishing between these allows your WordPress backend to handle the failure appropriately without crashing the user experience.
Logging these failures ensures you can track billing discrepancies or rate limit breaches later. Store the error message, timestamp, and the specific voice or model used. This data helps you debug whether the issue stems from your script logic or a transient network problem.
Check for HTTP 4xx or 5xx
Use the requests library to inspect response.status_code. If the code is 401, verify your API key is correct and active. If it is 429, you have exceeded the rate limit (10 requests per minute before the first top-up, 60 requests per minute after). For 500 errors, the server encountered an internal issue, but since failed requests are free, you can safely retry.
- 401: Invalid or revoked API key
- 400: Invalid JSON body or character limit exceeded
- 429: Rate limit exceeded (60 req/min)
- 500: Internal server error
Log failure reasons
Record the exact error response from the API. This includes the error type and message provided in the JSON body. Logging these details helps you identify patterns, such as specific voices failing under high load or consistent timeouts from certain network conditions.
- Log timestamp and request ID
- Store the raw error JSON response
- Record the text snippet length
- Note the voice and model used
Retry logic implementation
Implement exponential backoff for 5xx errors and 429 rate limits. Start with a short delay (e.g., 1 second) and double it for each retry attempt. Limit retries to three attempts to prevent your script from hanging indefinitely. This approach ensures resilience against transient network issues.
- Use exponential backoff for retries
- Limit retries to 3 attempts
- Skip retry for 4xx client errors
- Log successful retries for monitoring
Optimizing for WordPress
Integrating the API directly into your WordPress theme allows users to generate audio on demand without page reloads. This approach keeps your site lightweight while delivering high-quality audio episodes that complement your written content.
Use AJAX for frontend calls
Send text from your blog posts via AJAX to trigger synthesis. This ensures the user experience remains smooth, as the browser handles the request in the background while the API processes the audio file.
- Pass post ID and content via POST request
- Return audio URL in JSON response
- Update DOM without full page refresh
Store audio in media library
Save the returned binary audio data to your WordPress media library. This centralizes your audio assets, making them easier to manage and reference in future posts or playlists without relying on external temporary links.
- Use
wp_insert_attachmentto register files - Assign correct MIME types (mp3, wav)
- Link audio to specific post IDs
Embed with HTML5 player
Use the standard HTML5 <audio> tag to embed the generated files. This ensures broad compatibility across devices and browsers, allowing readers to control playback, volume, and seek functionality natively within your blog layout.
- Support for mp3, wav, opus, flac, pcm
- No external plugins required
- Accessible controls for all users

Testing Your Implementation
Testing ensures your Python script integrates smoothly with the SonicPress API before publishing audio to your WordPress site. Start by sending simple, short phrases to verify connectivity and authentication. This initial step confirms that your API key is valid and the endpoint responds correctly without consuming significant credits.
Run with short text first
Send a few sentences using the requests library or OpenAI SDK. Check that the response status is 200 and that audio data is returned. This quick validation prevents major integration issues when processing longer articles.
- Use a simple string like "Hello, this is a test."
- Verify the response contains binary audio data.
Verify audio quality
Download the generated audio file and play it locally. Listen for clarity, proper pacing, and correct language pronunciation. Since short phrases take a few seconds to generate, ensure your script waits for the full response before saving.
- Check for the inaudible synthetic watermark.
- Confirm voice matches your selected preset (e.g., aria, felix).
Check character counts
Ensure your input text does not exceed 4096 characters per request. Count spaces and punctuation as characters. If your article is longer, your script should split the text into parts, generate audio for each, and join them.
- Limit each API call to 4096 characters.
- Verify billing matches the actual character count used.
Scaling Your Deployment
Scaling your deployment involves moving from single-post generation to automated workflows that handle your entire content library efficiently. By processing posts in batches, you can convert weeks of articles into audio episodes without manual intervention, ensuring your WordPress site stays up-to-date with minimal effort.
Batch process multiple posts
Group your articles by length to maximize the 4096-character limit per request. Send multiple POST requests concurrently or sequentially, joining the resulting audio files into a single episode file. This approach reduces overhead and ensures consistent playback for your listeners.
- Group articles by similar length to optimize character usage.
- Join generated audio files sequentially for single playback.
- Reduce per-request overhead by batching related content.
Schedule overnight generation
Use cron jobs or WordPress schedulers to run your Python script during off-peak hours. This ensures that generation does not interfere with live site traffic or user experience. Since longer texts take roughly real-time to generate, scheduling allows you to process hundreds of articles while your users sleep.
- Run scripts during off-peak hours to avoid traffic interference.
- Process hundreds of articles while users are active.
- Use WordPress schedulers for automated daily runs.
Monitor API usage limits
Your key allows 60 requests per minute after the first top-up, and 10 requests per minute initially. Track your character consumption against the $10 per 1 million characters rate. Set up alerts if your batch processing approaches these limits to prevent throttling or unexpected delays in audio delivery.
- Key limit: 60 requests per minute after top-up.
- Rate: $10 per 1 million characters.
- Set alerts to prevent throttling during large batches.
Advanced Voice Customization
The API provides eight distinct voice presets, each with a specific tonal character suited for different content types. You can select any voice to match your brand's audio identity, ensuring consistency across all generated episodes. Every generated file carries an inaudible watermark that marks it as synthetic speech.
Select specific voices
Choose from female voices like Aria for clear narration or Nova for upbeat content, and male options like Felix for energetic promos or Atlas for neutral news. Each voice is designed for specific use cases, allowing you to tailor the listening experience.
- Aria: Warm, clear narrator
- Nova: Bright, upbeat
- Luna: Soft, storytelling
- Felix: Energetic, promo
- Atlas: Neutral, news
- Orion: Deep, documentary
Adjust speed parameters
Control the playback rate between 0.25 and 4.0 to fit your pacing needs. Slower speeds improve clarity for complex topics, while faster rates work well for short updates or summaries.
Set language codes manually
While the API guesses language from the script, explicitly setting the ISO language code ensures accuracy for non-English Latin text. This prevents mispronunciation and maintains the intended tone across 23 supported languages.
Common Pitfalls to Avoid
Developers often assume the 4096-character limit is flexible, but exceeding it causes silent failures or truncation. Since the API processes requests sequentially, ignoring this boundary can waste credits on incomplete audio files that never reach the WordPress media library.
Network timeouts are another common issue. Because generation takes time, especially for longer texts, relying on default timeout settings may lead to premature connection drops. Proper error handling ensures you retry only when necessary, avoiding unnecessary charges.
Ignoring character limits
The API strictly enforces a 4096-character maximum per request. If your script sends longer text without splitting, the request fails. You must implement logic to chunk text into valid segments before sending.
- Split input text at logical boundaries (sentences or paragraphs)
- Ensure each chunk is under 4096 characters
- Concatenate resulting audio files in code
Not handling network timeouts
Synthesis is not instant. Short phrases take a few seconds, while longer texts may take minutes. If your Python script times out too quickly, you will receive an error even though the request is still processing.
- Set timeout to at least 60 seconds
- Implement exponential backoff for retries
- Log specific HTTP error codes for debugging
Forgetting to rotate keys
Each account has one active key. If you lose it or suspect a leak, issue a new key immediately. The old key stops working at once, so ensure your script updates to the new value promptly to avoid downtime.
- Generate new key from /get-api-key/ dashboard
- Update environment variables in your deployment
- Verify old key is invalidated
Future Enhancements
Your current Python script handles direct API calls efficiently, but future updates can streamline the workflow further. By integrating caching, you reduce redundant API calls for identical posts, saving both time and character credits. This is particularly useful for static blog content that rarely changes.
Additionally, packaging your script into a native WordPress plugin would eliminate the need for external server setups. Note that we do not provide an official WordPress plugin. This allows editors to generate audio directly from the post editor, making the process seamless for non-technical users without requiring them to manage Python environments.
Add SSML support if available
While the API currently does not support SSML, future updates might introduce phoneme-level control. This would allow precise adjustments to pronunciation and pacing, enhancing accessibility for complex terminology.
If SSML becomes available, you could modify your Python script to inject tags into the text payload before sending it to the API.
Implement caching strategies
Caching generated audio files locally or via CDN prevents re-generating audio for unchanged posts. This significantly reduces API usage and costs over time.
You can extend your Python script to check a local database or file system before making a new API request, ensuring only new or updated posts trigger synthesis.
- Store hashed audio filenames in a local database
- Invalidate cache when post content is updated
- Serve cached audio via CDN for faster load times
Create a WordPress plugin
Converting your script into a WordPress plugin would allow direct integration with the post editor. This removes the need for external scripts or manual uploads.
The plugin could automate voice selection, speed settings, and audio embedding, making TTS accessible to all blog publishers without technical expertise.
This approach also simplifies updates and ensures compatibility with WordPress core updates.
- Integrate TTS generation directly into the post editor
- Automate audio file uploads to the media library
- Allow users to select voices and speed via settings
Listen to the 8 voices
Each sample below was generated by this API from the same sentence. Whether you are publishing news, personal essays, or technical guides, your specific words do not become part of the engine’s learning pool.
23 languages
Any voice speaks any of these languages.
