aws-polly is an integration library for the file conversion functionality of files to audio using aws polly. HTML to SSML is also included with SsmlCreator.php
aws-polly can be installed to your project via Composer by adding the following line to your composer.json file:
composer require "cidilabs/aws-polly": "dev-master"
"cidilabs/aws-polly": "dev-master"
Once aws-polly library is installed, you'll need to let UDOIT know which file conversion library you'll be using.
This can be done:
- In the .env:
AVAILABLE_FILE_FORMATS="pdf"
MP3_FILE_FORMAT_CLASS="\\CidiLabs\\Polly\\AwsPollyFileConversionProvider"
You will need to define your AWS Credentials in the AWS. For local the default is to put it in the env for docker-compose for your IAM Access keys. You should be using a EC2 IAM Role for AWS. In your docker-compose file
environment:
- AWS_ACCESS_KEY_ID=
- AWS_SECRET_ACCESS_KEY=
- fileName: The name of the file
- fileUrl: The download URL for the file
- fileType: The file type of the original file
- format: The file type that we want to convert to (usually mp3)
- S3Bucket: Bucket in S3 you want to place the file in.
- voice: voice you want to use
- TextType: MUST be ssml or text
- text: html that you want to convert
$polly = new AwsPollyFileConversionProvider();
$fileUrl = "https://cidilabs.instructure.com/files/295964/download?download_frd=1&verifier=RZwKCP3iVlNQIULZnTAXO0usUROMC9AuplKkDf2g";
$options = array('fileUrl' => $fileUrl, 'fileType' => 'pdf', 'format' => 'mp3', 'fileName' => 'Test1.pdf', 'S3Bucket' => 'polly' , 'voice' => 'Joanna', 'TextType' => 'ssml', 'text' => 'sample text');
$polly->convertFile($options);
- options: (array) Takes in options -- fileName: (string) The name of the file -- fileUrl: (string) The download URL for the file -- fileType: (string) The file type of the original file -- format: (string) The file type that we want to convert to -- Text: (String) in the end this is created by the function to transform html to ssml -- TextType: (String) The Type of Text, This MUST be ssml or text -- voice: The voice used in polly for the conversion -- S3Bucket: Where you want to put the polly converted files
- taskId: (string) The UUID representing the file conversion task
- null
- taskId: (string) The UUID representing the file conversion task
- True/False (boolean) True if the file has been converted and is ready, false otherwise
- taskId: (string) The UUID representing the file conversion task
- fileUrl: (string) The url of the converted file
- null
- bucket: (string) The bucket you want to download from
- key: (string) key of the object you are trying to access
- fileUrl: (string) The url of the converted file
- True/False (boolean) True if successfully deleted, false otherwise
- bucket: (string) The bucket you want to delete from
- key: (string) key of the object you are trying to delete
- text: (string) HTML to take in to convert to SSML
- data (string) SSML
- html: (string) brings in HTML to setup base before converting
- html: (string) returns base html
- html: (string) HTML to be converted to SSML
- ssml: (string) returns ssml
- childNodes: (Array) Array of ChildNodes of a DomElement
- node: (node) Brings in a node of a DomDocument
- node: (node) node of a DomDocument
- node: (node) Brings in a node of a DomDocument
- node: (node) node of a DomDocument
- html: (string) html to strip out tags
- html: (string) html without tags
- node: (node) node to change element name
- name: (string) name to change node to
- newnode: (node) returns a new node with the element or tag changed
- html: (string) html to make sure is clean before setting up base
- html: (string) returns html with doctype and head removed