Text To Speech

⌘K
  1. Home
  2. Docs
  3. Text To Speech
  4. Usage & Setup
  5. How to Fix the “Some Sentences Generate Audio That Is Too Long” Error in AtlasVoice Text to Speech Pro

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:

By implementing these changes, you can successfully generate MP3 files using Google Cloud Text to Speech without encountering the character limit error.

How can we help?