Link to home
Create AccountLog in
Avatar of Phonebuff
PhonebuffFlag for United States of America

asked on

PHP Script for AWS Poly Errors =

I am trying to develop a simple PHP that will read through a text file of Words and Phrases and then get a synthesized speech version of each entry from AWS Poly and finally save that response as an mp3 file for later processing by Audcity. 


I found some sample code here - https://saturncloud.io/blog/how-to-implement-amazon-polly-using-php-sdk/


But after using the Composer to install the SDK as referenced a simple PHP -f myFile.php results in errors on the very first line.  The use Aws\Polly\PollyClient; line,.  So I went digging into the tree installed by Composer and found the file vendor/aws/aws-sdk-php/src/Polly/PollyClient.php and added it via a require but again had no luck.   


Hoping someone can steer me in the right direction. 


On siteground so there are some long directory paths. 


so

<?php

require 'vendor/aws/aws-sdk-php/src/Polly/PollyClient.php';

use Aws\Polly\PollyClient;

.............

Fatal error: Uncaught Error: Class 'Aws\AwsClient' not found in /home/customer/www/dapage.net/aws/vendor/aws/aws-sdk-php/src/Polly/PollyClient.php:32

Stack trace:

#0 /home/customer/www/xxxxx.net/aws/awsPoly.php(3): require()

#1 {main}

  thrown in /home/customer/www/xxxxx.net/aws/vendor/aws/aws-sdk-php/src/Polly/PollyClient.php on line 32

ASKER CERTIFIED SOLUTION
Avatar of lenamtl
lenamtl
Flag of Canada image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Phonebuff

ASKER

Well that certainly helped --- 


Now I have a  Uncaught Error: Class 'Aws\Polly\Enum\OutputFormat'  --  


Despite the - use Aws\Polly\Enum\OutputFormat;


So more digging.   -- 




 




Never Mind, Can't find the enum list so I just hardcoded it and it works ---


Thank you