1. AWS Lambda Function
Written in Python.
Accepts POST requests with JSON body { "text": "Any Text" }.
Calls Amazon Polly to synthesize MP3 audio.
Uploads audio file to private S3 bucket.
Generates presigned URL valid for 1 hour.
Returns JSON response with presigned URL for audio playback.
2. API Gateway
REST API with a POST /upload method.
Lambda Proxy Integration enabled.
CORS enabled for cross-origin access from frontend.
3. S3 Bucket
Bucket name: polly-output-bucket-for-files
Bucket access: Private.
Lambda role has permissions to PutObject.
Audio files stored with unique filenames.
4. Frontend
Simple HTML + JavaScript.
Sends POST requests with input text to API Gateway.
Receives presigned URL and plays audio in browser.
Setup Instructions
Create S3 Bucket
Name it polly-output-bucket-for-files (or update code accordingly).
Keep it private (no public access).
Create IAM Role for Lambda
Attach policy allowing:
polly:SynthesizeSpeech
s3:PutObject on your bucket ARN.
Create Lambda Function
Use provided Python code (lambda_function.py).
Set timeout to at least 10 seconds.
Assign the IAM role created above.
Create API Gateway REST API
Create resource /upload.
Add POST method integrated with Lambda (Proxy Integration enabled).
Enable CORS on the resource.
Deploy API to a stage (e.g., dev).
Configure Frontend
Update index.html with your API Gateway invoke URL.
Serve the HTML file (locally or from any web host).
Test
Open frontend in browser.
Enter text and click "Generate Speech".
Audio will play after processing.
Actual Testing Link:
Notes
The presigned URL expires after 1 hour for security.