How to Fix the “Some Sentences Generate Audio That Is Too Long” Error in AtlasVoice Text to Speech Pro
If you’re encountering the error message:
cssCopy codeGoogle\ApiCore\ApiException: {
"message": "Some sentences generate audio that is too long.
Consider splitting up long sentences with sentence breaking punctuation (e.g., periods) and/or removing SSML tags.",
"code": 3,
"status": "INVALID_ARGUMENT",
"details": []
}
This error typically occurs when using the AtlasVoice Text to Speech Pro plugin with Google Cloud Text to Speech to generate MP3 files. The issue arises due to long sentences or large text inputs that exceed Google’s character limits for audio generation.
Solution: Adjust Character Limits with a Filter
To resolve this issue, you need to reduce the character limit for batch processing in your plugin. You can achieve this by applying a custom filter in your WordPress site. Here’s how:
phpCopy codeadd_filter('tts_pro_batch_charlen', function($batch_length_arr) {
$batch_length_arr = [
'initial_batch_charlen' => 450,
'latter_batch_char_length' => 490,
];
return $batch_length_arr;
});
This filter sets a limit on the number of characters processed in each batch, helping avoid the error.
Additional Resources
For more detailed information, you can refer to the following resources:
- Google TTS Error: Can’t Convert Text Longer than 500-600 Characters – Learn about the character limit issues with Google Cloud Text to Speech and how to avoid them.
- Google Cloud Text-to-Speech Quotas and Limits – Check the limits and quotas for using Google Cloud Text to Speech services.
By implementing these changes, you can successfully generate MP3 files using Google Cloud Text to Speech without encountering the character limit error.