Listen to music generated from new tweets on Twitter.
Iora is inspired by @debugger22’s GitHub Audio. I had it playing in the background at one point while working on this. 😄
Each incoming tweet is converted into a note and duration pair. There are five different types a tweet can be classified as: new tweet, retweet, reply, poll, and media (images, videos, GIFs), and a note is assigned according to that. The duration is calculated by dividing the tweet length by 70 (the amount of characters per fourth of a tweet at max length).
Iora is composed of three components:
- A Twitter app registered through the Twitter Developer Portal, which is used to access data from the platform
- A Node.js WebSockets server which interfaces with Twitter’s stream API via a long-lived HTTP connection. Received messages are re-broadcasted to all connected clients as WebSocket messages. This is necessary because Twitter restricts apps to one concurrent connection.
- A React.js frontend for music generation and displaying received data
- Go to Twitter’s Developer Portal and create a new app. Make sure the app is compatible with Twitter’s API V2.
- Go to Keys and tokens and note down the value of Bearer token.
Here are all the variables you need to set up on the server, with hints.
# Port to run the server on.
PORT=3000
# The URL to prepend to all built assets that'll be served.
PUBLIC_URL=https://iora.live
# Obtained from the Twitter Developer Portal.
TWITTER_BEARER_TOKEN=AAAA…
This section is only relevent to you if you’ve decided to run Iora on a platform other than Heroku.
git clone https://github.com/ifvictr/iora
cd iora
# Install dependencies
yarn
# Start Iora in production! This will build the source files and then run them.
yarn build
yarn start
# Or, if you need to run it in development mode instead. This will start both the backend and frontend and run them concurrently.
yarn dev
After you’ve followed all the above steps, you should see something like this in the console:
Starting Iora…
Listening on port 3000
Connected to Twitter stream