This project involves creating a serverless application that captures a phrase entered by the user and converts it into an MP3 audio file using AWS's Polly service.
To start working with this project, follow the steps below to install and set up the repository locally.
First, clone the project repository and access the api-tts/
folder using the following commands in the terminal:
git clone https://github.com/YeffersonSilva/AWS-Voicify-Serverless-Text-to-Speech-Solution.git
cd AWS-Voicify-Serverless-Text-to-Speech-Solution
The Serverless Framework is necessary for deploying the application. Install it globally on your computer:
npm install -g serverless
After generating your AWS credentials (AWS Access Key and AWS Secret) through IAM, configure them along with the necessary environment variables for the project.
S3_BUCKET=your-s3-bucket-name
DYNAMODB_TABLE=your-dynamodb-table-name
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=your-aws-access-key
AWS_SECRET_ACCESS_KEY=your-aws-secret-key
AWS_SESSION_TOKEN=your-aws-session-token-optional
To run the project locally with the Serverless Framework, you can use serverless offline to simulate the AWS Lambda and API Gateway environment on your local machine.
# Install the project dependencies
npm install
#Run the server locally
serverless offline
After executing the last command, the available endpoints for the application will be listed in your terminal.
To deploy the project on AWS, you can use the serverless deploy command. Make sure your credentials and environment variables are correctly configured and that you have assigned the necessary permissions to interact with the specified AWS services in the project.
serverless deploy
This will deploy your application on AWS using the provided credentials and settings. Upon successful completion, you will receive the API endpoints that can be publicly accessed.
- AWS Lambda: For executing backend code without managing servers.
- AWS API Gateway: To provide endpoints accessible to the end user.
- AWS S3: For storing the generated audio files.
- AWS Polly: For converting text to speech.
- AWS DynamoDB: For storing references of the conversions made.
- Serverless Framework: To facilitate the deployment of the application on AWS.
The application has been deployed and configured on AWS, using the serverless framework to simplify the deployment process and resource management. Available endpoints:
- **Version 1:
https://xxxx.execute-api.us-east-1.amazonaws.com/v1/tts
- Converts text to speech and stores the result in S3.
- **Version 2:
https://xxx.execute-api.us-east-1.amazonaws.com/v2/tts
- Extends version 1 by storing conversion references in DynamoDB.
- **Version 3:
https://xxx.execute-api.us-east-1.amazonaws.com/v3/tts
- Checks if a conversion has already been performed before proceeding, optimizing resource usage.