<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by JourdanBrown on Medium]]></title>
        <description><![CDATA[Stories by JourdanBrown on Medium]]></description>
        <link>https://medium.com/@jbrown0903?source=rss-ccf6c00f2bf1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xMedPi2uWhlNXIAL</url>
            <title>Stories by JourdanBrown on Medium</title>
            <link>https://medium.com/@jbrown0903?source=rss-ccf6c00f2bf1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 09:22:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jbrown0903/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building an Automated Text-to-Speech Pipeline with Amazon Polly, S3, and GitHub Actions]]></title>
            <link>https://medium.com/@jbrown0903/building-an-automated-text-to-speech-pipeline-with-amazon-polly-s3-and-github-actions-dc47110e1896?source=rss-ccf6c00f2bf1------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc47110e1896</guid>
            <category><![CDATA[amazon-polly]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[JourdanBrown]]></dc:creator>
            <pubDate>Mon, 15 Dec 2025 19:48:54 GMT</pubDate>
            <atom:updated>2025-12-15T19:48:54.728Z</atom:updated>
            <content:encoded><![CDATA[<h4>A complete guide to creating a serverless CI/CD pipeline for converting text to audio</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/141/1*1kIE-JF25adLE7KvOt4e2Q.png" /><figcaption>Architecture Diagram</figcaption></figure><h3>Building an Automated Text-to-Speech Pipeline with Amazon Polly, S3, and GitHub Actions</h3><p><em>A complete guide to creating a serverless CI/CD pipeline for converting text to audio</em></p><h3>Introduction</h3><p>In this tutorial, we’ll build an automated text-to-speech conversion pipeline using AWS services and GitHub Actions. By the end, you’ll have a system that automatically converts text files to high-quality audio whenever you make changes, with separate beta and production environments for proper quality assurance.</p><p><strong>What we’re building:</strong></p><ul><li>Automated text-to-speech conversion using Amazon Polly</li><li>Audio file storage in Amazon S3</li><li>CI/CD pipeline with GitHub Actions</li><li>Separate beta (preview) and production environments</li><li>No servers to manage — completely serverless!</li></ul><p><strong>Use cases:</strong></p><ul><li>Course content accessibility</li><li>Automated podcast generation</li><li>Audio book creation</li><li>Multi-language content delivery</li><li>Learning tools for visually impaired users</li></ul><h3>Architecture Overview</h3><pre>GitHub Repository (text changes)<br>    ↓<br>GitHub Actions (detects changes)<br>    ↓<br>Amazon Polly (converts text to speech)<br>    ↓<br>Amazon S3 (stores audio files)</pre><p><strong>Workflow:</strong></p><ol><li><strong>Pull Request created</strong> → Beta audio generated for review</li><li><strong>Pull Request merged</strong> → Production audio generated</li><li>Both versions stored in separate S3 folders</li></ol><h3>Prerequisites</h3><p>Before starting, ensure you have:</p><ul><li><strong>AWS Account</strong> with administrative access</li><li><strong>GitHub Account</strong></li><li><strong>Basic understanding of:</strong></li><li>Git and GitHub</li><li>Command line basics</li><li>AWS services (helpful but not required)</li></ul><p><strong>Estimated time:</strong> 60–90 minutes<br> <strong>Estimated cost:</strong> Less than $1/month for light usage</p><h3>Part 1: Setting Up AWS Resources</h3><h3>Step 1: Create an S3 Bucket</h3><p>Amazon S3 will store our generated audio files.</p><h4>Using AWS Console:</h4><p><strong>Navigate to S3:</strong></p><ul><li>Go to <a href="https://console.aws.amazon.com/">AWS Console</a></li><li>Search for “S3” in the top search bar</li><li>Click on <strong>S3</strong></li></ul><p><strong>Create bucket:</strong></p><ul><li>Click the orange <strong>“Create bucket”</strong> button</li></ul><p><strong>Configure bucket settings:</strong></p><ul><li><strong>Bucket name:</strong> polly-audio-bucket-[your-name]-[random-numbers]</li><li>Example: polly-audio-bucket-john-12345</li><li>Must be globally unique across all AWS accounts</li><li>Use lowercase, numbers, and hyphens only</li><li><strong>AWS Region:</strong> In my case, <strong>US East (N. Virginia) us-east-1</strong></li><li><strong>Object Ownership:</strong> Leave as “ACLs disabled (recommended)”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EuCavRpuQkL3gkRCTjkQJA.png" /></figure><p><strong>Block Public Access:</strong></p><ul><li><strong>Keep all boxes checked</strong> (Block all public access)</li><li>This keeps your audio files secure</li></ul><p><strong>Bucket Versioning:</strong></p><ul><li>Select <strong>“Enable”</strong></li><li>Allows you to keep multiple versions of files</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H6pRw__7ZrHA7MXNGuiNAA.png" /></figure><p><strong>Tags (optional but recommended):</strong></p><ul><li>Key: Project | Value: PollyTextToSpeech</li><li>Key: Environment | Value: Production</li></ul><p><strong>Default encryption:</strong></p><ul><li>Select <strong>“Server-side encryption with Amazon S3 managed keys (SSE-S3)”</strong></li><li>Enable Bucket Key</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LVxZNZyvBWwSe7fu7K9mNw.png" /></figure><p><strong>Click “Create bucket”</strong></p><p><strong>Success!</strong> You should see your bucket in the S3 buckets list.</p><p><strong>Save your bucket name — </strong>(I personally would use notepad to be able to copy and paste information that I would need later)</p><h3>Step 2: Create IAM User for GitHub Actions</h3><p>GitHub Actions needs AWS credentials to access Polly and S3.</p><h4>2.1: Create IAM Policy</h4><p><strong>Navigate to IAM:</strong></p><ul><li>Search for “IAM” in AWS Console</li><li>Click on <strong>IAM</strong></li></ul><p><strong>Create custom policy:</strong></p><ul><li>In the left sidebar, click <strong>“Policies”</strong></li><li>Click <strong>“Create policy”</strong> (orange button, top right)</li></ul><p><strong>Use JSON editor:</strong></p><ul><li>Click the <strong>“JSON”</strong> tab</li><li>Delete the default content</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fx_FD9slcCEJwXvCyTO7HQ.png" /></figure><ul><li>Paste this policy (replace your-bucket-name):</li></ul><p>json</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;PollySynthesis&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;polly:SynthesizeSpeech&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;*&quot;<br>    },<br>    {<br>      &quot;Sid&quot;: &quot;S3Upload&quot;,<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:PutObject&quot;,<br>        &quot;s3:PutObjectAcl&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::your-bucket-name/polly-audio/*&quot;<br>    }<br>  ]<br>}<br></pre><h4>2.2: Create IAM User</h4><p>1. Navigate to Users:<br> — In IAM, click **”Users” in the left sidebar<br> — Click **”Create user”<br>2. User details:<br> — User name: `github-actions-polly`<br> — Uncheck “Provide user access to the AWS Management Console”<br> — Click ”Next”<br>3. Set permissions:<br> — Select ”Attach policies directly”<br> — Search for and select: `GitHubActionsPollyPolicy`<br> — Click ”Next”<br>4. **Review and create:<br> — Review the settings<br> — Click **”Create user”</p><h4>2.3: Create Access Keys</h4><ol><li>Click on the user name `github-actions-polly`<br>2. Click the ”Security credentials” tab<br>3. Scroll to ”Access keys”<br>4. Click ”Create access key”<br>5. Select use case:<br> — Choose ”Third-party service”<br> — Check the confirmation box<br> — Click ”Next”<br>6. Add description (optional):<br> — Description: `GitHub Actions for Polly TTS`<br> — Click ”Create access key”<br>7. 🚨 CRITICAL: Save these credentials NOW<br> <br>(e.g.) You’ll see:<br>```<br> Access key ID: AKIAIOSFODNN7EXAMPLE<br> Secret access key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY</li></ol><p><strong>Options to save:</strong></p><ul><li>Download .csv file (recommended)</li><li>Copy to a password manager</li><li>Write them down temporarily</li></ul><p><strong>⚠️ You cannot retrieve the secret access key later!</strong></p><p>Click <strong>“Done”</strong></p><h3>Part 2: Setting Up GitHub Repository</h3><h3>Step 1: Create GitHub Repository</h3><ol><li><strong>Go to GitHub.com</strong> and sign in</li><li>Click the <strong>“+” icon</strong> (top right) → <strong>“New repository”</strong></li><li><strong>Repository settings:</strong></li></ol><ul><li><strong>Repository name:</strong> polly-text-to-speech</li><li><strong>Description:</strong> Automated text-to-speech conversion using Amazon Polly</li><li><strong>Visibility:</strong> Public (or Private if preferred)</li><li><strong>Check</strong> “Add a README file”</li><li><strong>Check</strong> “Add .gitignore” → Select <strong>Python</strong></li></ul><p>Click <strong>“Create repository”</strong></p><h3>Step 2: Add GitHub Secrets</h3><p>GitHub Secrets securely store your AWS credentials.</p><ol><li><strong>In your repository, click “Settings”</strong> (top menu)</li><li>Click <strong>“Secrets and variables”</strong> → <strong>“Actions”</strong> (left sidebar)</li><li>Click <strong>“New repository secret”</strong></li></ol><p><strong>Add three secrets:</strong></p><p><strong>Secret 1:</strong></p><ul><li>Name: AWS_ACCESS_KEY_ID</li><li>Secret: <em>[Paste your AWS Access Key ID]</em></li><li>Click <strong>“Add secret”</strong></li></ul><p><strong>Secret 2:</strong></p><ul><li>Name: AWS_SECRET_ACCESS_KEY</li><li>Secret: <em>[Paste your AWS Secret Access Key]</em></li><li>Click <strong>“Add secret”</strong></li></ul><p><strong>Secret 3:</strong></p><ul><li>Name: S3_BUCKET_NAME</li><li>Secret: <em>[Your S3 bucket name, e.g., </em><em>polly-audio-bucket-john-12345]</em></li><li>Click <strong>“Add secret”</strong></li></ul><p>You should now see three secrets listed.</p><h3>Step 3: Create Project Files</h3><p>We’ll create all files using GitHub’s web interface.</p><h4>3.1: Create speech.txt</h4><ol><li>Click <strong>“Add file”</strong> → <strong>“Create new file”</strong></li><li><strong>File name:</strong> speech.txt</li><li><strong>Content:</strong></li></ol><p>text</p><pre>Welcome to Pixel Learning Co. This is a sample audio course content that demonstrates our text-to-speech conversion pipeline. Amazon Polly provides high-quality, natural-sounding voices that make learning accessible to everyone.</pre><p><strong>Commit:</strong> Click <strong>“Commit new file”</strong></p><h4>3.2: Create requirements.txt</h4><ol><li><strong>Add file</strong> → <strong>Create new file</strong></li><li><strong>File name:</strong> requirements.txt</li></ol><p>boto3&gt;=1.26.104</p><p>This installs boto3 for later use, this is the latest version as of right now.</p><p><strong>Commit new file</strong></p><h4>3.3: Create synthesize.py</h4><ol><li><strong>Add file</strong> → <strong>Create new file</strong></li><li><strong>File name:</strong> synthesize.py</li><li><strong>Content:</strong></li></ol><p>python</p><pre>import boto3<br>import os<br>import sys<br>from datetime import datetime</pre><pre>def synthesize_speech(text_file, output_file, bucket_name, s3_key):<br>    &quot;&quot;&quot;<br>    Synthesize speech from text file and upload to S3<br>    <br>    Args:<br>        text_file: Path to input text file<br>        output_file: Local output filename<br>        bucket_name: S3 bucket name<br>        s3_key: S3 object key (path)<br>    &quot;&quot;&quot;<br>    # Read text content<br>    try:<br>        with open(text_file, &#39;r&#39;, encoding=&#39;utf-8&#39;) as f:<br>            text = f.read()<br>    except FileNotFoundError:<br>        print(f&quot;Error: {text_file} not found&quot;)<br>        sys.exit(1)<br>    <br>    # Initialize Polly client<br>    polly_client = boto3.client(&#39;polly&#39;, region_name=&#39;us-east-1&#39;)<br>    <br>    # Synthesize speech<br>    print(f&quot;Synthesizing speech from {text_file}...&quot;)<br>    try:<br>        response = polly_client.synthesize_speech(<br>            Text=text,<br>            OutputFormat=&#39;mp3&#39;,<br>            VoiceId=&#39;Joanna&#39;,<br>            Engine=&#39;neural&#39;<br>        )<br>    except Exception as e:<br>        print(f&quot;Error synthesizing speech: {e}&quot;)<br>        sys.exit(1)<br>    <br>    # Save audio to file<br>    print(f&quot;Saving audio to {output_file}...&quot;)<br>    with open(output_file, &#39;wb&#39;) as f:<br>        f.write(response[&#39;AudioStream&#39;].read())<br>    <br>    # Upload to S3<br>    print(f&quot;Uploading to S3: s3://{bucket_name}/{s3_key}&quot;)<br>    s3_client = boto3.client(&#39;s3&#39;, region_name=&#39;us-east-1&#39;)<br>    try:<br>        s3_client.upload_file(<br>            output_file,<br>            bucket_name,<br>            s3_key,<br>            ExtraArgs={&#39;ContentType&#39;: &#39;audio/mpeg&#39;}<br>        )<br>        print(f&quot;✓ Successfully uploaded to S3&quot;)<br>        print(f&quot;  URL: https://{bucket_name}.s3.amazonaws.com/{s3_key}&quot;)<br>    except Exception as e:<br>        print(f&quot;Error uploading to S3: {e}&quot;)<br>        sys.exit(1)</pre><pre>if __name__ == &quot;__main__&quot;:<br>    # Get configuration from environment variables<br>    bucket_name = os.environ.get(&#39;S3_BUCKET_NAME&#39;)<br>    environment = os.environ.get(&#39;ENVIRONMENT&#39;, &#39;beta&#39;)<br>    <br>    if not bucket_name:<br>        print(&quot;Error: S3_BUCKET_NAME environment variable not set&quot;)<br>        sys.exit(1)<br>    <br>    # Configuration<br>    text_file = &#39;speech.txt&#39;<br>    output_file = &#39;output.mp3&#39;<br>    s3_key = f&#39;polly-audio/{environment}.mp3&#39;<br>    <br>    print(f&quot;=== Polly Text-to-Speech Synthesis ===&quot;)<br>    print(f&quot;Environment: {environment}&quot;)<br>    print(f&quot;Input: {text_file}&quot;)<br>    print(f&quot;Output: {output_file}&quot;)<br>    print(f&quot;S3 Destination: s3://{bucket_name}/{s3_key}&quot;)<br>    print()<br>    <br>    synthesize_speech(text_file, output_file, bucket_name, s3_key)<br>    <br>    print(&quot;\n✓ Process completed successfully!&quot;)<br>```</pre><p>4. Commit new file</p><p>Troubleshooting: Indentation Errors<br> <br> If you encounter `IndentationError: unindent does not match any outer indentation level`, this means Python detected inconsistent spacing. Python requires consistent indentation (either 4 spaces or 1 tab throughout, not mixed).<br><br>Fix: Copy the code above exactly as shown. If pasting into GitHub’s editor, use “Select All” → “Delete” → then paste the fresh code. This ensures clean indentation.</p><p>3.4: Create GitHub Actions Workflows<br>Now we’ll create the automated workflows. The folder structure is critical.<br>Understanding `.github/workflows/’<br><br>GitHub Actions requires workflows to be in exactly this path: `.github/workflows/`<br>The dot at the beginning (`.github`) is required<br>Both folders are needed<br>Use forward slashes `/` even on Windows<br>Creating the folder structure:<br>When you type `.github/workflows/filename.yml` in the file name field, GitHub automatically creates the folders for you!<br> — -<br>3.5: Create Beta Workflow<br>1. Add file → Create new file<br>2. File name:** Type this EXACTLY:<br> .github/workflows/on_pull_request.yml</p><p>As you type, watch the breadcrumb at the top change:</p><ul><li>After .github/ → Shows: polly-text-to-speech / .github /</li><li>After workflows/ → Shows: polly-text-to-speech / .github / workflows /</li><li>After filename → Shows: polly-text-to-speech / .github / workflows / on_pull_request.yml</li></ul><ol><li><strong>Content:</strong></li></ol><p>yaml</p><pre>name: Polly Beta Synthesis (PR)</pre><pre>on:<br>  pull_request:<br>    branches:<br>      - main<br>    paths:<br>      - &#39;speech.txt&#39;<br>      - &#39;synthesize.py&#39;<br>      - &#39;.github/workflows/on_pull_request.yml&#39;</pre><pre>jobs:<br>  synthesize-beta:<br>    runs-on: ubuntu-latest<br>    <br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v3<br>      <br>      - name: Set up Python<br>        uses: actions/setup-python@v4<br>        with:<br>          python-version: &#39;3.9&#39;<br>      <br>      - name: Install dependencies<br>        run: |<br>          python -m pip install --upgrade pip<br>          pip install -r requirements.txt<br>      <br>      - name: Configure AWS credentials<br>        uses: aws-actions/configure-aws-credentials@v2<br>        with:<br>          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>          aws-region: us-east-1<br>      <br>      - name: Synthesize speech (Beta)<br>        env:<br>          S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}<br>          ENVIRONMENT: beta<br>        run: python synthesize.py<br>      <br>      - name: Comment on PR<br>        uses: actions/github-script@v6<br>        with:<br>          script: |<br>            github.rest.issues.createComment({<br>              issue_number: context.issue.number,<br>              owner: context.repo.owner,<br>              repo: context.repo.repo,<br>              body: &#39;✅ Beta audio synthesized and uploaded to S3!\n\n**Location:** `polly-audio/beta.mp3`\n\nReview the audio before merging to production.&#39;<br>            })<br>```</pre><pre>4. **Commit directly to main branch**</pre><pre>&gt; **⚠️ Troubleshooting: &quot;Resource not accessible by integration&quot;**<br>&gt;<br>&gt; If the workflow runs but fails on the &quot;Comment on PR&quot; step with error &quot;Resource not accessible by integration&quot;, GitHub Actions needs permission to comment on pull requests.<br>&gt;<br>&gt; **Fix:**<br>&gt; 1. Go to **Settings** → **Actions** → **General**<br>&gt; 2. Scroll to **&quot;Workflow permissions&quot;**<br>&gt; 3. Select **&quot;Read and write permissions&quot;**<br>&gt; 4. ✅ Check **&quot;Allow GitHub Actions to create and approve pull requests&quot;**<br>&gt; 5. Click **&quot;Save&quot;**<br>&gt; 6. Re-run the failed workflow<br>&gt;<br>&gt; Note: The audio file was likely still created successfully in S3 even though the workflow shows as &quot;failed&quot; — this error only affects the PR comment feature.</pre><pre>---</pre><pre>#### 3.6: Create Production Workflow</pre><pre>1. **Add file** → **Create new file**</pre><pre>2. **File name:**<br>```<br>   .github/workflows/on_merge.yml</pre><p>(GitHub remembers you’re in .github/workflows/ so you can just type the filename)</p><ol><li><strong>Content:</strong></li></ol><p>yaml</p><pre>name: Polly Prod Synthesis (Merge)</pre><pre>on:<br>  push:<br>    branches:<br>      - main<br>    paths:<br>      - &#39;speech.txt&#39;<br>      - &#39;synthesize.py&#39;</pre><pre>jobs:<br>  synthesize-prod:<br>    runs-on: ubuntu-latest<br>    <br>    steps:<br>      - name: Checkout code<br>        uses: actions/checkout@v3<br>      <br>      - name: Set up Python<br>        uses: actions/setup-python@v4<br>        with:<br>          python-version: &#39;3.9&#39;<br>      <br>      - name: Install dependencies<br>        run: |<br>          python -m pip install --upgrade pip<br>          pip install -r requirements.txt<br>      <br>      - name: Configure AWS credentials<br>        uses: aws-actions/configure-aws-credentials@v2<br>        with:<br>          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}<br>          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br>          aws-region: us-east-1<br>      <br>      - name: Synthesize speech (Production)<br>        env:<br>          S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}<br>          ENVIRONMENT: prod<br>        run: python synthesize.py<br>      <br>      - name: Create deployment summary<br>        run: |<br>          echo &quot;### 🎉 Production Deployment Complete&quot; &gt;&gt; $GITHUB_STEP_SUMMARY<br>          echo &quot;&quot; &gt;&gt; $GITHUB_STEP_SUMMARY<br>          echo &quot;**Environment:** Production&quot; &gt;&gt; $GITHUB_STEP_SUMMARY<br>          echo &quot;**Location:** \`polly-audio/prod.mp3\`&quot; &gt;&gt; $GITHUB_STEP_SUMMARY<br>          echo &quot;**Commit:** ${{ github.sha }}&quot; &gt;&gt; $GITHUB_STEP_SUMMARY<br>```</pre><pre>4. **Commit new file**</pre><pre>---</pre><pre>### Verify Repository Structure</pre><pre>Your repository should now have this structure:<br>```<br>polly-text-to-speech/<br>├── .github/<br>│   └── workflows/<br>│       ├── on_pull_request.yml<br>│       └── on_merge.yml<br>├── .gitignore<br>├── README.md<br>├── requirements.txt<br>├── speech.txt<br>└── synthesize.py</pre><p>To verify:</p><ol><li>Click on the <strong>Code</strong> tab</li><li>You should see all files listed</li><li>Click into .github → workflows to see both YAML files</li></ol><h3>Part 3: Testing the Pipeline</h3><p>Now let’s test that everything works!</p><h3>Step 1: Create a Test Pull Request</h3><h4>1.1: Create a new branch</h4><ol><li>Click the <strong>branch dropdown</strong> (says “main” with branch icon)</li><li>Type a new branch name: test-beta</li><li>Click <strong>“Create branch: test-beta from main”</strong></li></ol><p>You’re now on the test-beta branch.</p><h4>1.2: Edit speech.txt</h4><ol><li>Click on speech.txt</li><li>Click the <strong>pencil icon</strong> to edit</li><li>Change the content:</li></ol><pre>This is a test of the beta environment. Amazon Polly will convert this text to speech and upload it to the S3 bucket for review before production deployment.<br>```</pre><p>Commit changes:<br>Commit message: `Update speech.txt for beta test`<br>Select: **”Commit directly to the test-beta branch”<br>Click **”Commit changes”<br> — -<br>1.3: Create Pull Request<br>1. You should see a yellow banner: ”test-beta had recent pushes”<br>2. Click **”Compare &amp; pull request”<br> *If you don’t see the banner:*<br>Go to **Pull requests** tab<br>Click **”New pull request”<br> Base: `main` ← Compare: `test-beta`<br> Click **”Create pull request”<br>3. Pull request details:<br>Title: `Test beta synthesis workflow`<br>Description (optional): Add any notes<br> <br>4. Click **”Create pull request”**<br> — -<br>#### 1.4: Watch the Workflow Run<br>After creating the PR:<br>1. **Look for the workflow status** at the bottom of the PR:<br> — ⏳ Yellow circle = Running<br> — ✅ Green checkmark = Success<br> — ❌ Red X = Failed<br>2. **View details:**<br> — Click **”Details”** next to “Polly Beta Synthesis (PR)”<br> — Watch each step execute in real-time<br>**Expected workflow steps:**<br>```<br>✓ Checkout code<br>✓ Set up Python<br>✓ Install dependencies<br>✓ Configure AWS credentials<br>✓ Synthesize speech (Beta)<br>✓ Comment on PR<br>```<br> — -<br>#### 1.5: Verify Beta Audio<br>**In the workflow logs, you should see:**<br>```<br>=== Polly Text-to-Speech Synthesis ===<br>Environment: beta<br>Input: speech.txt<br>Output: output.mp3<br>S3 Destination: s3://polly-audio-bucket-john-12345/polly-audio/beta.mp3<br>Synthesizing speech from speech.txt…<br>Saving audio to output.mp3…<br>Uploading to S3: s3://polly-audio-bucket-john-12345/polly-audio/beta.mp3<br>✓ Successfully uploaded to S3<br> URL: <a href="https://polly-audio-bucket-john-12345.s3.amazonaws.com/polly-audio/beta.mp3">https://polly-audio-bucket-john-12345.s3.amazonaws.com/polly-audio/beta.mp3</a><br>✓ Process completed successfully!<br>```<br>Check S3:<br>1. Go to AWS S3 Console<br>2. Open your bucket<br>3. Navigate to `polly-audio/`<br>4. You should see: `beta.mp3`<br>5. Click on it → Download → Play the audio</p><p>Success! You should hear Joanna’s voice reading your text.<br>On the PR, you should also see a comment:**<br>```<br> Beta audio synthesized and uploaded to S3!<br>Location: polly-audio/beta.mp3<br>Review the audio before merging to production.<br>```<br> — -<br>Step 2: Merge to Production<br>After verifying the beta audio sounds good:<br>1. Scroll to the bottom of the PR<br>2. Click ”Merge pull request” (green button)<br>3. Click ”Confirm merge”<br>4. Optionally: Click ”Delete branch” (cleans up test-beta branch)<br> — -<br>2.1: Watch Production Workflow<br>1. Go to the Actions tab<br>2. You should see ”Polly Prod Synthesis (Merge)” running<br>3. Click on it to watch<br>Expected output:<br>```<br>=== Polly Text-to-Speech Synthesis ===<br>Environment: prod<br>Input: speech.txt<br>Output: output.mp3<br>S3 Destination: s3://polly-audio-bucket-john-12345/polly-audio/prod.mp3<br>Synthesizing speech from speech.txt…<br>Saving audio to output.mp3…<br>Uploading to S3: s3://polly-audio-bucket-john-12345/polly-audio/prod.mp3<br>✓ Successfully uploaded to S3<br>✓ Process completed successfully!</p><h4>2.2: Verify Production Audio</h4><p><strong>Check S3:</strong></p><ol><li>Go to your S3 bucket</li><li>Navigate to polly-audio/</li><li><strong>You should now see TWO files:</strong></li></ol><ul><li>beta.mp3 (from PR)</li><li>prod.mp3 (from merge)</li></ul><p>Download and play prod.mp3 to verify</p><h3>Understanding the Workflow</h3><blockquote><strong><em>Beta vs Production: How It Works</em></strong></blockquote><blockquote><em>Both beta and production use the </em><strong><em>same text</em></strong><em> from </em><em>speech.txt. The difference:</em></blockquote><ul><li><strong>Beta (Pull Request):</strong> Preview environment for quality assurance</li><li><strong>Production (Merge):</strong> Final deployment after approval</li></ul><blockquote><strong><em>Workflow:</em></strong></blockquote><ol><li>Edit speech.txt with your production content</li><li>Create PR → Beta audio generated</li><li>Download beta.mp3 and listen</li><li>If it sounds good → Merge</li><li>Production audio generated (identical content)</li></ol><blockquote><em>This ensures what you review in beta is exactly what goes to production.</em></blockquote><h3>Customization Options</h3><h3>Change the Voice</h3><p>In synthesize.py, line 30, change:</p><p>In python</p><pre>VoiceId=&#39;Joanna&#39;,  # Female US English</pre><p><strong>Popular alternatives:</strong></p><ul><li>&#39;Matthew&#39; — Male US English</li><li>&#39;Amy&#39; — Female British English</li><li>&#39;Brian&#39; — Male British English</li><li>&#39;Mizuki&#39; — Female Japanese</li><li>&#39;Zhiyu&#39; — Female Chinese</li></ul><p><a href="https://docs.aws.amazon.com/polly/latest/dg/voicelist.html">See all 60+ voices</a></p><h3>Change Audio Quality</h3><p>Line 31, change engine:</p><p>In python</p><pre>Engine=&#39;neural&#39;  # High quality (costs more)<br># or<br>Engine=&#39;standard&#39;  # Lower quality (costs less)</pre><p><strong>Pricing:</strong></p><ul><li>Neural: $16 per 1 million characters</li><li>Standard: $4 per 1 million characters</li></ul><h3>Add SSML Support</h3><p>For pronunciation control, pauses, emphasis:</p><p>In python</p><pre># In synthesize.py, modify the API call:<br>response = polly_client.synthesize_speech(<br>    Text=&#39;&lt;speak&gt;Hello &lt;break time=&quot;1s&quot;/&gt; world!&lt;/speak&gt;&#39;,<br>    TextType=&#39;ssml&#39;,  # Add this line<br>    OutputFormat=&#39;mp3&#39;,<br>    VoiceId=&#39;Joanna&#39;,<br>    Engine=&#39;neural&#39;<br>)</pre><p><a href="https://docs.aws.amazon.com/polly/latest/dg/ssml.html">SSML documentation</a></p><h3>Different Output Formats</h3><p>Line 29, change format:</p><p>python</p><pre>OutputFormat=&#39;mp3&#39;,<br># or<br>OutputFormat=&#39;ogg_vorbis&#39;,  # OGG format<br># or<br>OutputFormat=&#39;pcm&#39;,  # Raw audio (for processing)</pre><h3>Cost Breakdown</h3><p><strong>Monthly cost for light usage (estimated):</strong></p><blockquote>Service Usage Cost Amazon Polly (Neural)100,000 characters $1.60</blockquote><blockquote>Amazon S3 Storage1 GB $0.023</blockquote><blockquote>S3 Requests 100 uploads $0.0005</blockquote><blockquote>GitHub Actions Public repo Free <strong>Total~$1.63/month</strong></blockquote><p><strong>Free tier:</strong></p><ul><li>Polly: 5 million characters/month (first year)</li><li>S3: 5 GB storage, 20,000 GET requests (first year)</li><li>GitHub Actions: Unlimited for public repos</li></ul><h3>Troubleshooting Guide</h3><h3>Issue: Workflow doesn’t trigger</h3><p><strong>Symptoms:</strong> No workflow runs appear in Actions tab</p><p><strong>Solutions:</strong></p><ol><li>Check that workflow files are in .github/workflows/ (note the dot!)</li><li>Verify YAML file names: on_pull_request.yml and on_merge.yml</li><li>Ensure you’re editing the correct files (speech.txt or synthesize.py)</li><li>Check the paths: in workflow YAML matches files you changed</li></ol><h3>Issue: “AWS credentials not found”</h3><p><strong>Symptoms:</strong> Workflow fails at “Configure AWS credentials” step</p><p><strong>Solutions:</strong></p><ol><li>Go to Settings → Secrets and variables → Actions</li><li>Verify all three secrets exist:</li></ol><ul><li>AWS_ACCESS_KEY_ID</li><li>AWS_SECRET_ACCESS_KEY</li><li>S3_BUCKET_NAME</li></ul><ol><li>If missing, add them again</li><li>Make sure there are no extra spaces in the values</li></ol><h3>Issue: “Access Denied” to S3</h3><p><strong>Symptoms:</strong> Workflow fails at “Synthesize speech” step with access error</p><p><strong>Solutions:</strong></p><ol><li>Check IAM policy has correct bucket name</li><li>In IAM Console → Policies → GitHubActionsPollyPolicy → Edit</li><li>Verify the Resource ARN matches your bucket:</li></ol><pre>&quot;Resource&quot;: &quot;arn:aws:s3:::your-actual-bucket-name/polly-audio/*</pre><p>Save changes</p><h3>Issue: Indentation error in Python</h3><p><strong>Symptoms:</strong> Workflow fails with IndentationError</p><p><strong>Solution:</strong></p><ol><li>Go to synthesize.py in GitHub</li><li>Click edit (pencil symbol)</li><li>Select ALL content (Ctrl+A)</li><li>Delete it</li><li>Copy the code from this tutorial again</li><li>Paste (this ensures clean indentation)</li><li>Commit changes</li></ol><h3>Issue: PR comment not appearing</h3><p><strong>Symptoms:</strong> Workflow succeeds but no comment on PR</p><p><strong>Solution:</strong></p><ol><li>Settings → Actions → General</li><li>Scroll to “Workflow permissions”</li><li>Select “Read and write permissions”</li><li>Check “Allow GitHub Actions to create and approve pull requests”</li><li>Click Save</li><li>Re-run the workflow</li></ol><p><strong>Note:</strong> The audio file is still created successfully even if commenting fails!</p><h3>Issue: Audio file has wrong content</h3><p><strong>Symptoms:</strong> Downloaded MP3 doesn’t match speech.txt</p><p><strong>Solutions:</strong></p><ol><li>Verify you committed changes to speech.txt</li><li>Check the correct branch (test-beta for PRs, main for prod)</li><li>Look at workflow logs to see what text was processed</li><li>Try creating a new branch and PR</li></ol><h3>Security Best Practices</h3><h3>1. Rotate AWS Credentials Regularly</h3><p>Every 90 days:</p><ol><li>Create new access keys in IAM</li><li>Update GitHub secrets</li><li>Delete old access keys</li></ol><h3>2. Use Least-Privilege IAM Policy</h3><p>Our policy only grants:</p><ul><li>Polly: SynthesizeSpeech only</li><li>S3: PutObject only on specific path</li><li>No DeleteObject, GetObject, or other permissions</li></ul><h3>3. Enable S3 Bucket Versioning</h3><p>Already enabled in our setup! This allows:</p><ul><li>Recovering accidentally deleted files</li><li>Reverting to previous versions</li><li>Audit trail of changes</li></ul><h3>4. Monitor Usage</h3><p>Set up AWS Budgets:</p><ol><li>AWS Console → Billing → Budgets</li><li>Create budget</li><li>Set alert at $5/month</li><li>Get email if exceeded</li></ol><h3>5. Use Private Repository (Optional)</h3><p>For sensitive content:</p><ul><li>Make GitHub repo private</li><li>Still get 2,000 free Actions minutes/month</li><li>More secure for proprietary content</li></ul><h3>Next Steps</h3><p>Congratulations! You’ve built a complete serverless text-to-speech pipeline.</p><h3>1. Multiple Languages</h3><p>Create separate workflows for different languages:</p><ul><li>speech-en.txt → English (Joanna)</li><li>speech-es.txt → Spanish (Lupe)</li><li>speech-fr.txt → French (Celine)</li></ul><h3>4. CloudFront Distribution</h3><p>Serve audio files through CDN for faster delivery:</p><ol><li>Create CloudFront distribution</li><li>Point to S3 bucket</li><li>Get fast, global access to audio</li></ol><h3>5. Advanced Implementation</h3><p>Continue to Part 2 of this series:</p><ul><li><strong>Lambda Functions</strong> instead of GitHub Actions</li><li><strong>API Gateway</strong> for on-demand synthesis</li><li><strong>Infrastructure as Code</strong> with Terraform/CloudFormation</li><li><strong>Timestamp-based file versioning</strong></li></ul><h3>Conclusion</h3><p>You’ve successfully built a production-ready, serverless text-to-speech pipeline!</p><p><strong>What you’ve learned:</strong></p><ul><li>AWS S3 bucket configuration</li><li>IAM policies and users</li><li>GitHub Actions CI/CD</li><li>Amazon Polly text-to-speech</li><li>Environment separation (beta/prod)</li><li>Troubleshooting common issues</li></ul><p><strong>Key benefits of this approach:</strong></p><ul><li><strong>Fully automated</strong> — no manual steps</li><li><strong>Cost-effective</strong> — pay only for what you use</li><li><strong>Secure</strong> — credentials in GitHub Secrets</li><li><strong>Quality assurance</strong> — beta testing before production</li><li><strong>Scalable</strong> — handles any amount of content</li></ul><h3>Resources</h3><p><strong>Documentation:</strong></p><ul><li><a href="https://docs.aws.amazon.com/polly/">Amazon Polly Developer Guide</a></li><li><a href="https://docs.github.com/en/actions">GitHub Actions Documentation</a></li><li><a href="https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/polly.html">Boto3 Polly Reference</a></li></ul><p><strong>Next Tutorial:</strong></p><ul><li>Part 2: Advanced Implementation with Lambda &amp; API Gateway</li></ul><h3>About the Author</h3><p><em>Jourdan Brown</em></p><p><a href="https://www.linkedin.com/in/jourdanbrown/">https://www.linkedin.com/in/jourdanbrown/</a></p><p><a href="https://github.com/JourdanBrown/polly-text-to-speech">https://github.com/JourdanBrown/polly-text-to-speech</a></p><p><strong>Questions or issues?</strong> Leave a comment below or open an issue on the GitHub repository!</p><p><strong>Found this helpful?</strong> Please give it a star on GitHub and share with others!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc47110e1896" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>