in admin/AmazonAI-PollyService.php [542:604]
public function ajax_bulk_synthesize() {
check_ajax_referer( 'pollyajaxnonce', 'nonce' );
$batch_size = 1;
$common = $this->common;
$post_types_supported = $common->get_posttypes_array();
$amazon_polly_voice_id = $common->get_voice_id();
$amazon_polly_sample_rate = $common->get_sample_rate();
$amazon_polly_audio_location = ( 'on' === get_option( 'amazon_polly_s3' ) ) ? 's3' : 'local';
// We are using a hash of these values to improve the speed of queries.
$amazon_polly_settings_hash = md5( $amazon_polly_voice_id . $amazon_polly_sample_rate . $amazon_polly_audio_location );
$args = array(
'posts_per_page' => $batch_size,
'post_type' => $post_types_supported,
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'amazon_polly_audio_link_location',
'compare' => 'NOT EXISTS',
),
array(
'key' => 'amazon_polly_voice_id',
'value' => $amazon_polly_voice_id,
'compare' => '!=',
),
array(
'key' => 'amazon_polly_sample_rate',
'value' => $amazon_polly_sample_rate,
'compare' => '!=',
),
array(
'key' => 'amazon_polly_audio_location',
'value' => $amazon_polly_audio_location,
'compare' => '!=',
),
),
);
$query = new WP_Query( $args );
$post_ids = wp_list_pluck( $query->posts, 'ID' );
if ( is_array( $post_ids ) && ! empty( $post_ids ) ) {
foreach ( $post_ids as $post_id ) {
$clean_text = $common->clean_text( $post_id, true, false);
$sentences = $common->break_text( $clean_text );
$wp_filesystem = $common->prepare_wp_filesystem();
$this->convert_to_audio( $post_id, $amazon_polly_sample_rate, $amazon_polly_voice_id, $sentences, $wp_filesystem, '' );
}
} else {
$step = 'done';
}
$percentage = $this->get_percentage_complete();
echo wp_json_encode(
array(
'step' => $step,
'percentage' => $percentage,
)
);
wp_die();
}