This code generates and distributes the podcast The Weather in Brooklyn. It is intended to be run as a daily cron job. For the story behind this code, check out Could a Podcast Make Itself?.
Running the application executes the following steps:
- Pull the current forecast for Brooklyn from the National Weather Service API.
- Generate an editorial description of today's weather using OpenAI's completions endpoint (GPT-3 model).
- Incorporate this forecast and description into a script for the podcast episode in SSML format.
- Use Amazon Polly to convert the script SSML into an audio file of spoken words.
- Download the audio logo and music for the podcast episode from a designated S3 bucket.
- Using SoX, mix the audio components—logo, music, and speech—into the final episode audio.
- Upload the episode audio to S3.
- Update the podcast RSS feed on S3 with the new episode data.
The application expects two S3 bucket to exist, one private and one publicly readable.
The private bucket should contain a music/
folder that contains .mp3
files with source music, as well as the audio logo at logo/logo.mp3
.
The public bucket should contain the podcast art as art.jpg
. The podcast RSS feed and audio files will also be hosted here once the application creates them.
The application requires several environment variables to be defined. These can defined in ./.env
.
AWS_ACCESS_KEY_ID
: AWS keyAWS_SECRET_ACCESS_KEY
: AWS secret keyAWS_REGION
: AWS region for the S3 bucketsS3_PUBLIC_BUCKET
: Name of publicly readable S3 bucketS3_PRIVATE_BUCKET
: Name of private S3 bucketS3_EPISODES_FOLDER
: Name of folder in the public bucket where episode audio files live.S3_FEED_FILE_NAME
: Name of the file in the public bucket where the public RSS feed lives.OPENAI_ACCESS_TOKEN
: OpenAI API token.
If running with Docker, simply build the docker image:
$ ./bin/docker/build.sh
If running natively on OS X:
- Install brew.
- Install Lame:
$ brew install lame
- Install SoX with Lame:
$ brew install sox --with-lame
- Install Bundler:
$ gem install bundler
- Install Ruby gems:
$ bundle install
Running with Docker:
$ ./bin/docker/run.sh
Running on OS X:
$ ruby bin/run.rb
To launch an IRB session with the app environment loaded:
$ bin/irb.sh
Tests exercise the app's behavior with all netwrok requests stubbed out. To run tests:
$ bundle exec rspec