Project: Audio Notes
A Text-to-Speech Web Application.
About the Project
Context
This project was inspired by an idea found on the ACloudGuru website while studying Terraform and AWS. The initial concept was to create a webpage that allows users to input text, select from available voices, and receive an audio output of the text read in the chosen voice.
Initial Project Overview
The first iteration of the project involved a static website hosted on AWS S3 and delivered through CloudFront.
Workflow
Creating a Note:
- Users input text and select a voice on the website.
- The request is sent to API Gateway.
- A Lambda function is triggered by the API Gateway
- This function writes the text and voice selection to DynamoDB.
- The Lambda function also publishes the DynamoDB item ID to an SNS topic.
- A second Lambda function, subscribed to the SNS topic, is triggered.
- This function requests Amazon Polly to synthesize the audio from the text.
- The audio file is stored in an S3 bucket.
- The DynamoDB item is updated with the URL of the audio file.
Listing Notes:
- Users request the list of notes on the website.
- The request is sent to API Gateway.
- A Lambda function is triggered by the API Gateway
- The Lambda function retrieves items from DynamoDB.
The AWS resources for the ACloudGuru project were created manually in the AWS console. However, to leverage the benefits of Infrastructure as Code (IaC), Terraform was used to automate the creation of these resources.
Benefits of IaC and Terraform
Infrastructure as Code (IaC) allows for the automation of infrastructure deployment, ensuring consistency, accuracy, and speed. Terraform, in particular, provides a declarative approach to defining infrastructure, making it easier to manage and version control. It supports multiple cloud providers and enables the creation of modular, reusable components, leading to efficient and scalable infrastructure management.
Updates and Improvements
The Lambda functions were transitioned from Python to Go. Despite requiring more code, Go offers significantly faster execution, reducing costs and improving response times due to AWS Lambda's billing based on execution time.
Enhanced Project with User Authentication
In addition to the adoption of Terraform and the conversion of Lambda functions from Python to Go, I introduced another significant enhancement to the original project. The subsequent phase of the project incorporated user authentication, which allows the creation of both public and private notes. This was accomplished by utilizing Next.js in conjunction with AWS Amplify and Cognito for authentication, authorization, and user management.
Workflow
Creating a Note:
- Users access the website hosted on AWS Amplify.
- Users can and sign in using Cognito
- When a new note is created, it is stored in DynamoDB.
- A DynamoDB Stream triggers a Lambda function.
- The function publishes a message about the new note to an SNS topic.
- A new Lambda function is triggered by the SNS message.
- This function requests Amazon Polly to synthesize the audio from the text.
- The audio file is stored in an S3 bucket.
- The DynamoDB item is updated with the URL of the audio file.
Listing Notes:
- Users request the list of notes on the website.
- Users can and sign in using Cognito
- The Amplify retrieves items from DynamoDB.