ajax form function error

This error is telling you that there was a 500 error in the PHP of your AJAX callback:

jquery.js:8625 POST /admin-ajax.php 500 ()

This would be caused by a syntax error or other coding mistake.

In looking at your code one obvious major problem is here:

// use \Aws\Polly\PollyClient; // this was moved to before get_header in my template page where my form is. 
    //require '/aws-autoloader.php'; // this was moved to before get_header in my template page where my form is.

And here:

$client = new PollyClient($config);

For that second piece of code to work you need to load the PHP file that contains the PollyClient class. The first bit of code suggests to me that it is not being loaded. This is because you have put the require and use in the template, but the template is not oging to be loaded on an AJAX request. You need to require the file from within your theme’s functions file or within the AJAX callback function. Not doing this would cause a 500 error that would explain your issue. If your look at your error log you’ll likely see something about the class PollyClient not existing.

There could be other issues in the code, I’m not certain, I just saw this one and noted the issue. But essentially the problem is that you have a PHP coding issue/s in your polly_process() function.